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

[REBOL] Re: Q&D button maker

From: anton::wilddsl::net::au at: 7-Mar-2006 0:16

Hi Steven, yes it's cool ! :) But I had a look and found that you probably do not need to set words to your button faces at all, as the faces are available in each button action. So you can have the same functionality with even less code ! :) Have at look at this console session:
>> layout [b: button [print "hi"]] >> print mold get in b 'action
func [face value][print "hi"] As you can see, the action facet of the button face is a function which takes two arguments FACE and VALUE. When the action function is called, the View system passes the face whose action is being done in the FACE argument. This means the action code can refer to FACE if it wants to find out anything about the button. An example will make things clearer. Your code can be simplified like this: layout [ style button button 260x55 font-size 14 button "Add a new reservation/invoice" [ save-button %btnresadd.png to-image face ] button "etc" ] So you can see the reference to face removes the need for setting a word to each button. :) I've thrown in another optimization with the LAYOUT dialect keyword, STYLE. It just restyles the BUTTON style with some default facet values, which saves specifying them for every button. (Mmm.. and you could move TO-IMAGE inside SAVE-BUTTON... but I'll leave that to you.) Regards, Anton.