World: r3wp
[I'm new] Ask any question, and a helpful person will try to answer.
older newer | first last |
Henrik 21-Jan-2008 [1169] | Anton's made a version that has undo/redo, right? |
Anton 21-Jan-2008 [1170x3] | You can copy the code from the default engage function, but you will fall into a trap; some of the words used in the default engage handler are bound to specific contexts. Your code will bind all the words in your context or global context. I'm talking about the words focal-face (which is in system/view), unlight-text, highlight-start, highlight-end and edit-text (which are in ctx-text). |
So you should bind your code first to system/view, then to ctx-text, before making the function: | |
style my-field field feel [ engage: func [face action event] bind bind [ ; your code which uses focal-face, unlight-text etc... ] system/view ctx-text ] | |
SteveT 21-Jan-2008 [1173] | Ok, just found some mention of ctx-text in the docs. |
Anton 21-Jan-2008 [1174] | Henrik, unlimited undo/redo. |
Henrik 21-Jan-2008 [1175] | probably a good idea to learn about bindings first to know what it means :-) |
Anton 21-Jan-2008 [1176x2] | My edit-panel style is actually based on PANEL style, but pretty much supplants AREA, if you're happy with monospace font. (I haven't supported a single-line FIELD-like style, but could be easily done I expect.) |
See the Editors group to try out the edit-panel style. | |
SteveT 21-Jan-2008 [1178] | One other funcionality I'm missing is to be able to set the tab order ! They won't always be the presented order. And wether CR should act a sTAB or not. |
Anton 21-Jan-2008 [1179x2] | Aha... the built-in tab-cycling system is simplistic. I made my own but it still goes in pane order. |
whether CR can act as tab can be determined with a face flag. | |
SteveT 21-Jan-2008 [1181] | Ok thanks, Tab order might be cobbled by enlosing field in two or more vertical panels. Sorry missed the flag for CR. |
Anton 21-Jan-2008 [1182x2] | layout [f: field] probe f/flags ; == [field return tabbed on-unfocus input] view layout [f: field with [deflag-face self return]] |
AREA does not have the 'return flag. probe svv/vid-styles/area/flags ; == [tabbed on-unfocus input] | |
SteveT 21-Jan-2008 [1184] | whats svv ? |
Anton 21-Jan-2008 [1185x3] | You could also handle key events and trap the tab key, directing the focus to any face you like. |
system/view/vid | |
A very handy shortcut. | |
SteveT 21-Jan-2008 [1188] | ah thanks |
Anton 21-Jan-2008 [1189] | view layout [field feel [insert body: second :engage bind [if all [act = 'key event/key = tab][focus f3 exit]] body/2] field f3: field "This is f3"] |
SteveT 21-Jan-2008 [1190] | I knew all this was possible, and I know a lot of people prefer things at this level to cover their own requirement. But, returning to my original point. To make Rebol more general use - we need standard behaviour like this at a highr level? |
Henrik 21-Jan-2008 [1191] | absolutely. VID3 will not require this level of knowledge to produce something useful and complete. |
Anton 21-Jan-2008 [1192] | I agree too. |
SteveT 21-Jan-2008 [1193] | Thanks Anton - what I was missing in my efforts last night was the 'exit' that obviously releases the event. I was getting frustrated cos it just sits there doing nothing ;-) |
Anton 21-Jan-2008 [1194] | Yeah I forgot it first time around too. |
SteveT 21-Jan-2008 [1195] | So with the 'all' 'exit' combination you are handling any events (keypresses) you like in a form of 'switch' ? |
Anton 21-Jan-2008 [1196x2] | if all the following conditions are true: - the act (action, same as event/type) = 'key (and not 'down, 'up mouse presses etc.) - the event/key = tab (the tab character) then: focus a face exit |
I've inserted that at the top of the function body, so if we handle the tab char key event, then we exit and it doesn't have a chance to be handled by the rest of the default code (which actually calls upon the large edit-text function from ctx-text to handle key events). | |
SteveT 21-Jan-2008 [1198] | With 'ALL' and 'ANY' - in parse you also have 'SOME'. If you do 'exit' does it exit the event trap or can it move onto another event? |
Anton 21-Jan-2008 [1199x2] | The parse dialect words 'all' and 'any' are not the same as normal rebol 'all' and 'any'. Don't get confused by that. |
We're not using parse here. | |
SteveT 21-Jan-2008 [1201] | Got it! |
Anton 21-Jan-2008 [1202] | (Note that the above example where I set 'body is a bit "polluting". It sets the 'body word global. It's not strictly necessary, you can just replace body/2 with second second :engage. I just added it to make the meaning clearer.) |
SteveT 21-Jan-2008 [1203] | I wondered if the Rebol versions ended up becoming a lower-level parse. |
Anton 21-Jan-2008 [1204] | Mmm.. I don't think so... |
SteveT 21-Jan-2008 [1205] | So, can we have one engage that can act upon more than one event? I think that's my question! |
Anton 21-Jan-2008 [1206x4] | Of course. Which events ? |
My example shows how to inject any code you like. | |
Ah, you wanted to filter out non-number characters, etc ? | |
yeah just exit when not find "0123456789" event/key | |
SteveT 21-Jan-2008 [1210x2] | Yes, on a particular field I want to control what the user can and can't enter |
On one field I want to trap and convert any chars to uppercase, but also stopthe user from antering more than say 5 chars ! | |
Anton 21-Jan-2008 [1212x2] | either 5 > length? face/text [ ; allow event to pass through ][ exit ; too many chars ! don't allow it ! ] |
or combining filter with length check: if any [ not find "0123...89" event/key 5 <= length? face/text ][ exit ] | |
SteveT 21-Jan-2008 [1214x2] | Yeah I was trying to approach it with ( if chars < 6 allow it ) which got me in a mess. |
I'm sorry for all these questions - It sounds like I want you to do my work for me! I don't maind having to figure some things out myself . But I was asked to present waht I found difficult from a newbie point of view. | |
Henrik 21-Jan-2008 [1216] | you're lucky to have us around, otherwise some of this would take a long time to figure out. I was frustrated for a long time about many of these things. |
SteveT 21-Jan-2008 [1217] | Very True, hopefully I will be able give back - in time |
Henrik 21-Jan-2008 [1218] | particularly bindings can be baffling, because it looks like function names are pulled out of thin air. :-) |
older newer | first last |