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

[REBOL] Re: current face?

From: brett:codeconscious at: 7-May-2001 11:16

Hi Graham, I think Carl's example script was meant to highlight that the problem is already solved. When you create an action block for a style it becomes the specification block for a function that takes FACE as an argument. The face is the one you expect. This nice little solution guarantees you always get the correct face. Here I can show it: layout [ the-button: button "Some text" [ print face/text ] ] print mold get in the-button 'action So concisely, an action block is a function, FACE is an argument to this function and therefore face/text is a normal Rebol expression. To your script then. The reference to face/text is in the wrong spot - should be part of an action block on the "this works" button. Where it is now it should have been currentface/text. So I'll change the existing print and put a new one on the button. Also using this same technique of getting FACE as a parameter I can remove the need to label your example text style "ex1:" Here is the modified code: show-example: func [currentface] [ xy: 10x20 print join "face text is: " currentface/text if value? 'xview [xy: xview/offset unview/only xview] xcode: load/all currentface/text if not block? xcode [xcode: reduce [xcode]] ;!!! fix load/all ; check to see if xcode includes the 'layout word. If it does, ; then move past it if here: select xcode 'layout [xcode: here] if error? try [xview: view/new/offset layout xcode xy] [ alert "Unable to view this code"] ] view center-face layout [ backdrop white text as-is { button "this works" [ print join "face text is: " face/text ] } [show-example face] ] Cheers, Brett.