Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

change text of button...

 [1/8] from: djo::wanadoo::fr at: 28-Jun-2003 22:00


Hi i am a newbie in Rebol... and in english ! Sorry ! Is it possible to change the text of a button during execution ? for example, i load a file which contains the text and i would write this text in a button... Thanks A+ DJO

 [2/8] from: greggirwin:mindspring at: 28-Jun-2003 15:18


Hi Denis-Jo, DJ> i am a newbie in Rebol... and in english ! Sorry ! You're English is fine! DJ> Is it possible to change the text of a button during execution ? for example, DJ> i load a file which contains the text and i would write this text in a DJ> button... Yes, here the FACE word refers to the face the action is attached to, so you don't have to name it: view layout [button "Original" [face/text: "New!" show face]] Here, we set B to refer to the button so we can affect it. view layout [b: button "Original" [b/text: "New!" show b]] When you start building dynamic screens, the first thing you'll probably start doing is separating your VIEW and LAYOUT calls. It's often easier to call LAYOUT, which creates all the faces, then change them as necessary, then call VIEW. Alternatively, you can build your entire layout dynamically (or use COMPOSE against a layout you have built if that will do all you need) before even calling LAYOUT. REBOL gives you lots of flexibility. -- Gregg

 [3/8] from: greggirwin:mindspring at: 28-Jun-2003 16:02


Reply to self -- GI> You're English is fine! But mine has apparently lost its way. :\ *Your* English is fine. :) -- Gregg

 [4/8] from: carl::cybercraft::co::nz at: 24-Dec-2003 22:21


On 29-Jun-03, Denis-Jo wrote:
> Hi > i am a newbie in Rebol... and in english ! Sorry ! > Is it possible to change the text of a button during execution ? for > example, i load a file which contains the text and i would write > this text in a button...
Hi Denis, and welcome to REBOL. Yes, it's easy to change button text. The button's text is held in a block called texts. Change its contents and you'll change the text. ie... view layout [ b: button "Button" button "Change" [ b/texts: ["New"] show b ] ] Also, if there's two strings in the block you can have seperate text for when the button's in or out, like so... view layout [ b: button "Button" button "Change" [ b/texts: ["Out" "In"] show b ] ] Hope that helps. -- Carl Read

 [5/8] from: djo:wanadoo at: 29-Jun-2003 8:28


Le Samedi 28 Juin 2003 22:00, vous avez écrit :
> Hi > i am a newbie in Rebol... and in english ! Sorry !
<<quoted lines omitted: 4>>
> A+ > DJO
Thanks for all... But i have make a test program : REBOL [] view layout [ button "GAG" [face/text: "aaa" show face] ;not correct b: button "PUB" [b/text: "new" show b] ;not correct button "CCC" [b/texts: ["BBB"] show b] ;CORRECT button "DDD" [b/texts: ["new" "more"] show b] ;CORRECT button "EEE" [e/texts: ["new" "more"] show e] ;not correct e: rotary "RRR" "SSS" [] button "FFF" [f/texts: ["new 111" "more 222"] show f] ;CORRECT f: toggle "111" "222" [] ]

 [6/8] from: djo:wanadoo at: 29-Jun-2003 8:25


view layout [button "Original" [face/text: "New!" show face]] Here, we set B to refer to the button so we can affect it. view layout [b: button "Original" [b/text: "New!" show b]] Le Samedi 28 Juin 2003 22:00, vous avez écrit :

 [7/8] from: djo:wanadoo at: 29-Jun-2003 8:33


Le Samedi 28 Juin 2003 22:00, vous avez écrit :
> Hi > > i am a newbie in Rebol... and in english ! Sorry ! > > Is it possible to change the text of a button during execution ? for > example, i load a file which contains the text and i would write this text > in a button... >
Thanks for Gregg and Carl.... But i have make a test : view layout [ button "GAG" [face/text: "aaa" show face] ;not correct b: button "PUB" [b/text: "new" show b] ;not correct button "CCC" [b/texts: ["BBB"] show b] ;CORRECT button "DDD" [b/texts: ["new" "more"] show b] ;CORRECT button "EEE" [e/texts: ["new" "more"] show e] ;not correct e: rotary "RRR" "SSS" [] button "FFF" [f/texts: ["new 111" "more 222"] show f] ;CORRECT f: toggle "111" "222" [] ] Is it something for rotary ? Thanks A+ DJO

 [8/8] from: carl:cybercraft at: 24-Dec-2003 22:21


On 29-Jun-03, Denis-Jo wrote:
> button "EEE" [e/texts: ["new" "more"] show e] ;not correct > e: rotary "RRR" "SSS" [] > button "FFF" [f/texts: ["new 111" "more 222"] show f]
;CORRECT
> f: toggle "111" "222" [] > ] > Is it something for rotary ?
Try this... num: 0 view layout [ r: rotary "aaa" "bbb" button "Add Number" [ append r/texts to-string num show r num: num + 1 ] button "Select bbb" [ r/data: find r/texts "bbb" show r ] ] (Note that you can just copy & paste the above into the REBOL Console to run it - you don't need to save it as a REBOL script and then DO the script.) With the rotary style, both its 'texts and 'data words reference the block that contains the rotary's strings. The difference is in the words' indexes. 'texts's index points to the start of the block while 'data's index points to what's currently selected by the rotary. So to alter the strings in the rotary, alter the contents of the block that 'texts references. And to change what's selected in rotary, change the index of 'data. You can find out all the words a style has by probing the style after you exit back to the Console. This is what the rotary style (for 'r above) returns...
>> probe first r
[self type offset size span pane text color image effect data edge font para feel saved-area rate show? options parent-face old-offset old-size line-list changes face-flags action state style alt-action facets related words colors texts file var keycode reset styles init multi blinker pane-size dirty? help user-data flags effects] You can then look at the individual words like so...
>> probe r/texts
["aaa" "bbb"] == ["aaa" "bbb"]
>> probe r/data
["aaa" "bbb"] == ["aaa" "bbb"]
>> probe r/text
aaa == "aaa" and so on. If I'd changed the rotary before exiting, then r/data and r/text would show the change. Hope that helps. -- Carl Read

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted