Results 1 to 19 of 19
  1.    #1  
    A couple of fellow devs have taken me up on my offer on providing some webOS development help/tips. As a newbie myself, that is how I've learned to do my apps (asking other devs, scouring development web pages). So here goes #1:

    Copy to clipboard functionality:
    PS. This will make more sense if you buy my app (shameless plug/ but really).


    From palm.developer.com:
    Code:
    Mojo.Controller.StageController.setClipboard(escapeHTML:, escapeHTML)
    This allows the client application to send text to the clipboard to be pasted elsewhere later.
    
    Parameters:
    {Boolean} escapeHTML:
    ignored in initial setClipboard api; later will allow pasting of rich text
    escapeHTML
    From webOS 101:
    Code:
    Copying Text to the Clipboard
    this.controller.stageController.setClipboard('hello webos',true);
    In my app I wanted a button to copy the Morphed Text into the clipboard without having to have the user
    1) select the text using the shift key and their finger, and then
    2) have to go to the App Menu go down to edit and find "Copy" (or do a "Meta-Tap"-C copy command).

    In Ares I created a button, by dragging it from the palette to the middle design/code panel. I then selected the button and went to the Events section of the right hand attributes panel. I picked the onTap event as the one I wanted to have activated by clicking the little add code icon in the empty field. Ares then takes me to the code for the scene I'm in with the follwing already created:
    button3Tap: function(inSender, event) {
    I add the stuff from earlier and voilą, functional copy to clipboard button.
    button3Tap: function(inSender, event) {
    this.controller.stageController.setClipboard (document.a.x.value);
    It took me maybe an hour to figure out how to add document.formName.tableName.value into the parenthesis by checking out javascript code examples on the web, but now you have it here....


    For extra credit: I added a banner notification to let the user know that the text was copied:
    button3Tap: function(inSender, event) {
    this.controller.stageController.setClipboard (document.a.x.value);

    this.sendNotification2();
    },
    sendNotification2: function() {
    var message = "Upside Down Text Copied";
    var appController = Mojo.Controller.getAppController();
    var bannerParams = {
    messageText: message
    };
    appController.showBanner(bannerParams, {banner: message});

    },
    Well, that's it for now. I gotta go to my Great-Recession-Part-Time-Janitor-Job and unclog toilets...
    If you have any of my apps and would like to know how I did something , just ask.

    Manny
    Last edited by Mannyman; 12/10/2010 at 08:48 PM. Reason: typo
    APP & Patch Makers Get on the:webOS Developers Map
    My Apps: Presentation Controller (for PowerPoint and Open Office Impress), PC Display Master ,Handheld X-Ray H.E. (Halloween Edition), Text Morpher ⓦⓘⓣⓗ ⓑⓤⓑⓑⓛⓔ ⓣⓔⓧⓣ plus Ŧεẍṫ ℉яεαḱεя
  2. #2  
    How do I specify what it's supposed to be copying?

    Uncaught TypeError: Cannot read property 'x' of object (app/assistants/AsIAm-assistant.jsjsjs:$11$)
    I have an HTML box full of text.

    Thanks

    webOS Developer
  3.    #3  
    Quote Originally Posted by roneyii View Post
    How do I specify what it's supposed to be copying?

    I have an HTML box full of text.

    Thanks
    Good question. Remember that took me another hour(s) to figure out.
    Let's try to figure it out together. Don't do what I did and let someone else write all your code for you. Make your brain sweat at it until it hurts...


    What is the name of your html box?
    How would you ID it for webOS to eventually grab the contents of it?
    In your HTML box add this as the 1st line:
    Code:
    <form name="MannymanRulez">
    Then try this as your tap event:
    Code:
    this.controller.stageController.setClipboard (document.MannymanRulez.value);
    Will that work? I don't know.
    Is your HTML box a form or something else?
    By trying (and maybe failing) and then trying something else is where the fun comes in.

    If it's not fun, you may not be cut out for development... (This comment is for everyone including myself.)

    If we're lucky a non-newbie will chime in and set us straight.

    Let me know,
    Manny
    APP & Patch Makers Get on the:webOS Developers Map
    My Apps: Presentation Controller (for PowerPoint and Open Office Impress), PC Display Master ,Handheld X-Ray H.E. (Halloween Edition), Text Morpher ⓦⓘⓣⓗ ⓑⓤⓑⓑⓛⓔ ⓣⓔⓧⓣ plus Ŧεẍṫ ℉яεαḱεя
  4.    #4  
    Quote Originally Posted by roneyii View Post
    How do I specify what it's supposed to be copying?

    Uncaught TypeError: Cannot read property 'x' of object (app/assistants/AsIAm-assistant.jsjsjs:$11$)
    I have an HTML box full of text.

    Thanks
    Oh, another thing. Looking at your error the 'x' makes me think you just copy/pasted my example without using your own names for objects.

    In my app I have a form with 2 text areas.

    For this tutorial Let's say I called the form "a" and one of the text areas "x".

    That way when I use the following, webOS or javascript knows what I'm referring to.

    Code:
    button3Tap: function(inSender, event) {
    this.controller.stageController.setClipboard (document.a.x.value);
    I guess the next question may be: How do I name everything?
    I showed you already how to name a form:
    Code:
    <form name="MannymanRulez">
    Here's how to name the text field within the form:
    Code:
    <textarea rows="4" cols="34" style="font-size:1.1em" name="ForRealz"></textarea>
    So then...the button tap code would look like:
    Code:
    button3Tap: function(inSender, event) {
    this.controller.stageController.setClipboard (document.MannymanRulez.ForRealz.value);
    APP & Patch Makers Get on the:webOS Developers Map
    My Apps: Presentation Controller (for PowerPoint and Open Office Impress), PC Display Master ,Handheld X-Ray H.E. (Halloween Edition), Text Morpher ⓦⓘⓣⓗ ⓑⓤⓑⓑⓛⓔ ⓣⓔⓧⓣ plus Ŧεẍṫ ℉яεαḱεя
  5. #5  
    Quote Originally Posted by Mannyman View Post

    What is the name of your html box?
    html1
    Original, I know.

    Quote Originally Posted by Mannyman View Post
    How would you ID it for webOS to eventually grab the contents of it?
    In your HTML box add this as the 1st line:
    Code:
    <form name="MannymanRulez">
    Then try this as your tap event:
    Code:
    this.controller.stageController.setClipboard (document.MannymanRulez.value);
    Will that work? I don't know.
    We're getting warmer.
    The banner notification now pops up, but my text isn't actually copied.
    Clicking Paste in the memos app pastes "Undefined".

    Quote Originally Posted by Mannyman View Post
    Is your HTML box a form or something else?
    It's the standard Ares HTML UI Widget.

    webOS Developer
  6.    #6  
    Did you name the html1 textbox: MannyRulez or html1 by using:
    Code:
    <form name="MannymanRulez">
    or
    Code:
    <form name="html1">
    ?
    APP & Patch Makers Get on the:webOS Developers Map
    My Apps: Presentation Controller (for PowerPoint and Open Office Impress), PC Display Master ,Handheld X-Ray H.E. (Halloween Edition), Text Morpher ⓦⓘⓣⓗ ⓑⓤⓑⓑⓛⓔ ⓣⓔⓧⓣ plus Ŧεẍṫ ℉яεαḱεя
  7. #7  
    Quote Originally Posted by Mannyman View Post
    Oh, another thing. Looking at your error the 'x' makes me think you just copy/pasted my example without using your own names for objects.
    I removed my failed names before posting the error.

    Back to tinkering with the code. I think I'm making progress.

    Thanks.

    webOS Developer
  8.    #8  
    If you want post your html1 box here or PM me with it or email it and I'll see if anything I'm saying applies....
    APP & Patch Makers Get on the:webOS Developers Map
    My Apps: Presentation Controller (for PowerPoint and Open Office Impress), PC Display Master ,Handheld X-Ray H.E. (Halloween Edition), Text Morpher ⓦⓘⓣⓗ ⓑⓤⓑⓑⓛⓔ ⓣⓔⓧⓣ plus Ŧεẍṫ ℉яεαḱεя
  9. #9  
    Quote Originally Posted by Mannyman View Post
    If you want post your html1 box here or PM me with it or email it and I'll see if anything I'm saying applies....
    Not sure the best way to post it.
    Do these screen caps help?





    I tinkered and ended up clearing out my text and had to replace it. Oops.

    (But yes, it is fun!)

    webOS Developer
  10. #10  
    Okay, so the pics don't show here on the forum, but you can right-click 'em to open them and they work.

    webOS Developer
  11.    #11  

    Try making putting this as the last line of your html box :
    Code:
    </form>
    It is html after all.

    Let me know,
    Manny

    PS.
    In Flikr:
    I went to your image, and
    pressed the share button,
    then "grab the html/bbcode option"
    then looked for "img src="
    then used the http location of your jpg: http://farm6.static.flickr.com/5287/...e926db966b.jpg
    Last edited by Mannyman; 12/11/2010 at 04:16 PM. Reason: how to embed flikr images
    APP & Patch Makers Get on the:webOS Developers Map
    My Apps: Presentation Controller (for PowerPoint and Open Office Impress), PC Display Master ,Handheld X-Ray H.E. (Halloween Edition), Text Morpher ⓦⓘⓣⓗ ⓑⓤⓑⓑⓛⓔ ⓣⓔⓧⓣ plus Ŧεẍṫ ℉яεαḱεя
  12. #12  
    Already tried that.

    And the "textarea" code throws everything out of wack.

    Makes it a user input field.

    Tinker, tinker...

    -- Sent from my Palm Pre using Forums Beta

    webOS Developer
  13.    #13  
    Quote Originally Posted by roneyii View Post
    Already tried that.

    And the "textarea" code throws everything out of wack.

    Makes it a user input field.

    Tinker, tinker...

    -- Sent from my Palm Pre using Forums Beta
    Yep, my app uses user input fields, so take it or leave it....
    But now you got me curious...
    Looking on the interwebs I found this :
    If you want to access the text within a non-input HTML element, then you are going to have to use the innerHTML property instead of value. The next lesson goes into more detail about the uses of innerHTML.
    It may be a clue for what we're looking for...
    APP & Patch Makers Get on the:webOS Developers Map
    My Apps: Presentation Controller (for PowerPoint and Open Office Impress), PC Display Master ,Handheld X-Ray H.E. (Halloween Edition), Text Morpher ⓦⓘⓣⓗ ⓑⓤⓑⓑⓛⓔ ⓣⓔⓧⓣ plus Ŧεẍṫ ℉яεαḱεя
  14. #14  
    Thanks.

    You got me further than I was.

    -- Sent from my Palm Pre using Forums Beta

    webOS Developer
  15.    #15  
    Check this out:
    Javascript Tutorial - innerHTML

    So in your html box: ID your text something like
    Code:
    <p id='lyrics'>
    The rest of your text
    </p>
    and then in the tap event try something like:
    Code:
    this.controller.stageController.setClipboard (getElementById('lyrics').innerHTML);
    Too busy to try myself but let me know...
    EDIT: I was close but the final answer is at the bottom of this post.



    Using the example from the following post I figured out a really easy way of doing it.

    I added a button that copies the label widget's contents to the clipboard.
    Here is the tapEvent:
    Code:
    button3Tap: function(inSender, event) {
    		this.controller.stageController.setClipboard (this.$.label1.label);
    	}
    For the Grand Finale:
    How to copy the text in the html1 widget box:
    I added another button called copy html1 to clipboard

    I gave it the following tapEvent:
    Code:
    		
    this.controller.stageController.setClipboard (document.getElementById('text').innerHTML +(' ')+ document.getElementById('boldStuff').innerHTML );
    If you look at the html1 contentnts it should make sense:
    Code:
     <big id='text'style="font-size:16pt;">
    Welcome to webOS,</big> <big><b id='boldStuff'>dude.</b></big>
    Notice two IDs:
    'boldStuff' was already there for the change dude to Luke action.
    'text' was added to get the text in front of dude/luke
    Last edited by Mannyman; 12/24/2010 at 03:35 AM. Reason: Found answer
    APP & Patch Makers Get on the:webOS Developers Map
    My Apps: Presentation Controller (for PowerPoint and Open Office Impress), PC Display Master ,Handheld X-Ray H.E. (Halloween Edition), Text Morpher ⓦⓘⓣⓗ ⓑⓤⓑⓑⓛⓔ ⓣⓔⓧⓣ plus Ŧεẍṫ ℉яεαḱεя
  16.    #16  
    How to have a button change text on screen:



    There's at least a couple of ways to do it. The following Screencaps show an additional button added, but with another method to change the text.

    Example 1 was from that site I was learning from. The other was from searching in the Palm development forum for "change label".
    Here's how:
    A) The 1st sentence was placed in an html widget.
    The content was filled with this
    Code:
    <p>Welcome to webOS, <b id='boldStuff'>dude.</b> </p>


    B) Next I created a new document in the app folder called changetxt.jsjsjs $and$ $put$ $this$ $into$ $it$:

    Code:
    function changeText(){
       document.getElementById('boldStuff').innerHTML = 'Luke!';
    }
    
    C) Then I had to update the sources.json file to tell webOS about the document I just created:
    Code:
          {
          "source": "app\/changetxt.jsjsjs&$quot$;,
                       }
    D) Dragged a button to the canvas and set the following as a tapEvent

    Code:
       
    button1Tap: function(inSender, event) {
          changeText();
       },
    For the second example:

    1) Dragged a Label onto the canvas
    2) Dragged a button onto the canvas
    3) Added the following tapEvent to the new button:
    Code:
       button2Tap: function(inSender, event) {
    this.$.label1.setLabel('This is a Cool Label');
       }
    APP & Patch Makers Get on the:webOS Developers Map
    My Apps: Presentation Controller (for PowerPoint and Open Office Impress), PC Display Master ,Handheld X-Ray H.E. (Halloween Edition), Text Morpher ⓦⓘⓣⓗ ⓑⓤⓑⓑⓛⓔ ⓣⓔⓧⓣ plus Ŧεẍṫ ℉яεαḱεя
  17.    #17  
    Here's something I just learned how to do.
    Replace the default buttons with your own images.
    Here's an example from the latest app I'm working on where the default buttons just aren't as cool as the custom ones.






    Last edited by Mannyman; 06/06/2011 at 10:58 PM. Reason: screengrabs too big
    APP & Patch Makers Get on the:webOS Developers Map
    My Apps: Presentation Controller (for PowerPoint and Open Office Impress), PC Display Master ,Handheld X-Ray H.E. (Halloween Edition), Text Morpher ⓦⓘⓣⓗ ⓑⓤⓑⓑⓛⓔ ⓣⓔⓧⓣ plus Ŧεẍṫ ℉яεαḱεя
  18. #18  
    I have a question...it's OT, but I don't want to start another thread and the newbie in the title just called out to me...lol.... I was at the book store and saw a book on how to develop for webos using mojo...I have ZERO programming knowledge, should I pick up the book or is it a waste of time since they are changing things? It was at half price books for about 6 bucks. The weight control/diet apps don't have what I'm looking for, so I figure I will eventually have to make my own.
    The value of knowledge is not in its possession, but in its use.
  19.    #19  
    Enyo is the future for webOS, can't wait for a book on it.

    $6 buck is super cheap. I'd get it.
    But, if money is tight I recommend getting a good book on javascript.
    APP & Patch Makers Get on the:webOS Developers Map
    My Apps: Presentation Controller (for PowerPoint and Open Office Impress), PC Display Master ,Handheld X-Ray H.E. (Halloween Edition), Text Morpher ⓦⓘⓣⓗ ⓑⓤⓑⓑⓛⓔ ⓣⓔⓧⓣ plus Ŧεẍṫ ℉яεαḱεя

Posting Permissions