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.


----- Original Message -----
From: "Graham Chiu" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 07, 2001 5:44 AM
Subject: [REBOL] Re: current face?


> On Sun, 6 May 2001 10:05:00 -0700
>  "Carl Sassenrath" <[EMAIL PROTECTED]> wrote:
> >  view layout [
> >    button "Some text" [ print face/text ]
> >  ]
>
> Doesn't work for me in this example
>
> Rebol []
>
> ; modified from easyVid
> show-example: func [ currentface ] [
> xy: 10x20
> print join "face text is: " face/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
> ex1: text as-is {
> button "this works"
> } [ show-example ex1 ]
> ]
>
> --
> Graham Chiu
> --
> To unsubscribe from this list, please send an email to
> [EMAIL PROTECTED] with "unsubscribe" in the
> subject, without the quotes.
>

-- 
To unsubscribe from this list, please send an email to
[EMAIL PROTECTED] with "unsubscribe" in the 
subject, without the quotes.

Reply via email to