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

[REBOL] Re: Rebol/View 'Key Event Problem

From: henrikmk:gmai:l at: 7-Oct-2009 19:27

On Wed, Oct 7, 2009 at 4:45 PM, Thorsten Moeller <> wrote:
> Hi, > > i am just writing a small editor for myself which should have a realtime > wordcount. Simplified i have following situation: > > editor: layout [ mytext: area ifo: info btn "Close" [unview]] > > view editor > > I am not too familiar with events in rebol. From the docs i learned that > i have to change the area definition to something like the following to > make the area react on key events: > > =A0 =A0 mytext: area feel [ > =A0 =A0 =A0 =A0engage: func [face action event] [ > =A0 =A0 =A0 =A0 =A0 =A0if action = 'key [mylen: length? parse mytext/text none > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0ifo/text: join "Wordcount: " copy to-string mylen > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0show if > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0] > > But just adding the feel to the area doesn't work. > > What am i missing??
You are, with that code above, replacing the original engage function for 'mytext, which contains all the text editing functions, so text editing stops working. Other than that, your code would normally be correct. Unfortunately there is no simple way in VID to just add an on-key handler without rewriting the real engage function that is used in the area style. You can see it like this: probe get in get in get-style 'area 'feel 'engage The solution is to modify that function and include it again. Cumbersome. :-) You can also download the VID Extension Kit, which lets you do your task, like this: view make-window [ ; ifo and if faces here my-text: area on-key [ act [ mylen: length? parse mytext/text none ifo/text: join "Wordcount: " copy to-string mylen show if ] ] ] It can be downloaded from here: -- Regards, Henrik Mikael Kristensen