The quotation you pass to the <border-button> constructor gets called by
the system when the button is pressed. At this time, the stack has nothing
to do with the stack shown in the listener. So you don't have the reference
to the label.

To have a reference to the label when the quotation is called, you should
make a closure. This can be done with "curry" (or, in this case, the more
appropriate "with"):

"Test" <label> dup gadget.
"Press" [ drop "Worked" >>text drop ] with <border-button> gadget.

Other ways of creating closures are fried quotations (
http://docs.factorcode.org/content/article-fry.html) or local variables (
http://docs.factorcode.org/content/article-locals.html)

Cheers,
Jon



On Mon, Dec 17, 2012 at 10:48 PM, Samuel Proulx <proulxsam...@gmail.com>wrote:

> Hi,
>
> Yet another problem... Hopefully the last though.
>
> I tried to make a button that changes the text slot of a previously made
> label. Here's what I did:
>
> "Test" <label> dup gadget.
> "Press" [ drop "Worked" >>text ] <border-button> gadget.
>
> I got an error message saying "Data stack underflow" when I clicked it. So
> I checked the quotation stack effect:
>
> [ drop "Worked" >>text ] infer.
> ( x x -- x )
>
> It should take the button, drop it since I don't need it, take the label,
> and then change its text to "Worked". It doesn't do it though. What did I
> do wrong?
>
> Thanks in advance,
> Samuel
>
>
> ------------------------------------------------------------------------------
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> _______________________________________________
> Factor-talk mailing list
> Factor-talk@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>
>
------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d
_______________________________________________
Factor-talk mailing list
Factor-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to