World: r3wp
[View] discuss view related issues
older newer | first last |
Anton 15-Nov-2005 [3216x6] | Oh no! We get an error message! "edit-text has no value". Where is EDIT-TEXT ? It is not defined in the global context. If you go looking in the system you will eventually find it here: CTX-EDIT/EDIT-TEXT What happened ? The original EDIT-TEXT word, as found in the FIELD/FEEL, is bound to CTX-EDIT (it's not found in the global context, open a new console and try it), but we only bound our new EDIT-TEXT word to a new function context (ie. our ENGAGE). So how do we keep the original bindings of a function, when making a copy of it ? SECOND gives you the body of a function. second get in svv/vid-styles/field/feel 'engage We should COPY that, which keeps the bindings, then modify that copy. *Then* we can create the function: ; copy the engage function body body: copy/deep second get in svv/vid-styles/field/feel 'engage ; <-- modify the body here ; make the new function engage: func [face act event] body Let's test that to see which keys we want: |
view/new layout [ the-field: field feel [ use [body at-key-block key-block][ ; copy the engage function body body: copy/deep second get in svv/vid-styles/field/feel 'engage ; modify the copy to move the block with the EDIT-TEXT word in it ; to a new IF then-block at-key-block: next find select body [switch act] [key] key-block: at-key-block/1 change/only at-key-block compose/only [probe event/key if true (key-block)] ; make the new function engage: func [face act event] body ] ] ] focus the-field do-events | |
Now filter for the desired keys: | |
view/new layout [ the-field: field feel [ use [body at-key-block key-block][ ; copy the engage function body body: copy/deep second get in svv/vid-styles/field/feel 'engage ; modify the copy to move the block with the EDIT-TEXT word in it ; to a new IF then-block at-key-block: next find select body [switch act] [key] key-block: at-key-block/1 change/only at-key-block compose/only [ if find "-0123456789.^H^-" event/key (key-block) ] ; make the new function engage: func [face act event] body ] ] new-field: field ] focus the-field do-events | |
Of course you can add more conditions to the filter, to only allow the minus sign at the beginning etc, but I leave that to you. :) | |
Graham, if you have trouble, maybe convert to base 64 using ENBASE ? | |
Graham 16-Nov-2005 [3222] | arrow 0x0 turns off arrows .. |
DideC 16-Nov-2005 [3223x2] | Anton: or you can double bind your code block to ctx-text and system/view |
view/new layout [ the-field: field feel [ engage: func [face act event] bind bind [ switch act [ down [ either equal? face focal-face [unlight-text] [focus/no-show face] caret: offset-to-caret face event/offset show face ] over [ if not-equal? caret offset-to-caret face event/offset [ if not highlight-start [highlight-start: caret] highlight-end: caret: offset-to-caret face event/offset show face ] ] key [ edit-text face event get in face 'action ] ] ] in ctx-text 'self in system/view 'self ] new-field: field ] focus the-field do-events | |
Volker 16-Nov-2005 [3225] | first question, is how can i get the first text field to accept mouse click events? Use the original feel can i update the position of the text curser in the number field cursor is in system/view/caret. points to the text in your face, use series-functions to move cursor recycling of feel: either dump and patch as shown here, or use traditional inheritance/super-call as shown in http://polly.rebol.it/test/test/extend-engage.r |
Henrik 16-Nov-2005 [3226] | is there a good way to do font substitution? I can see that under Windows, when I attempt to use the Tahoma font, OSX uses Lucida Grande and Linux turns to Courier for some reason. Is there a way to control that+ |
Rebolek 16-Nov-2005 [3227] | Henrik you can check for OS (something like 1.3.1.O.S) and then choose the right font |
Henrik 16-Nov-2005 [3228] | alrighty then... |
Graham 16-Nov-2005 [3229x5] | Regarding the security restrictions in draw dialect, the draw block is not reduced and so block evaluation is prevented. |
This means I can't do this ... [pen 0.0.0 line-width 2 fill-pen none font make object! [ name: "Sans Serif" style: [] size: 20 color: 0.0.0 offset: 14x0 space: 0x0 align: 'center valign: 'middle shadow: none colors: none ] text "testing" 79x63] | |
I have to supply the font as a word, and lookup the font outside the draw block. | |
I think this is too restrictive ( if I understand it correctly ) ! | |
If this is the case, I suggest that a font dialect be created to support fonts inside the draw dialect | |
Graham 17-Nov-2005 [3234x8] | This is my hack of Frank's paint.r program http://www.compkarori.com/reb/paintplus.r |
paint image [ image! none! ] data [block!] if given an image as first parameter, it loads it. If not, it creates a canvas of 300x300 if given a data block of draw commands, it applies it to the canvas | |
It adds freehand drawing, arrows, and text. **BUT** can't load back in text yet due to the restrictions on fonts above. | |
if data block is empty, it ignores it. | |
This is a simplistic tool is to be used to mark up images to point out areas of interest in medical images. | |
Feel free to fix it for me before uploading to the Rebol.org ( forgot my password ... ) | |
Frank had a very clever way of creating the draw block, but I found I couldn't do it the same way with all the combinations that were emerging. | |
Bizarre .. loading text works in this version ! | |
Volker 17-Nov-2005 [3242] | A syntax-trick: #[object![a: 123]] |
Graham 17-Nov-2005 [3243] | huh? |
Volker 17-Nov-2005 [3244] | try that for your font |
Graham 17-Nov-2005 [3245x2] | it's working anyway now! |
Ahh... I see. My other version used mold and not mold/all :( | |
Anton 17-Nov-2005 [3247] | Graham, I notice with arrow, undo/redo and circle, it's possible to get a circle with an arrow-head on it. |
Graham 17-Nov-2005 [3248x2] | yes ... :( |
that's what I was saying .. arrow is a state | |
Anton 17-Nov-2005 [3250x2] | DideC, yes, that is a simpler solution to this particular problem. I guess I wanted to show a more general way, keeping the original binding, instead of guessing what the binding should be. |
Graham, oh I see. Not really your fault then ? | |
Graham 17-Nov-2005 [3252x3] | and if you undo on an arrow draw, you lose the state setting, and so everything after that has arrows on it :( |
I can catch when you change from arrow to something else... but .. if I undo, I can't ... | |
probably needs some type of stack | |
Anton 17-Nov-2005 [3255] | It sounds like arrow should not be a tool, rather a mode that affects all/most tools. |
Graham 17-Nov-2005 [3256] | Hmm. Perhaps so. |
Anton 17-Nov-2005 [3257x2] | Otherwise I suggest switch arrow on, draw line with arrow head on it, switch arrow off. |
If it's a mode, then it should be a check-box, not a radio. | |
Graham 17-Nov-2005 [3259x2] | I did that before I realised it was a state. |
that might work .. undo the arrow immediately after the draw. | |
Anton 17-Nov-2005 [3261x2] | Actually, even if it's a mode, you should compose the draw block like (very pseudo-code): compose [ (either arrow-on? [enable-arrow][]) (draw-cmd-eg.line) (either arrow-on? [disable-arrow][]) ] |
Just ideas, I didn't look at the code this time. | |
Graham 17-Nov-2005 [3263x2] | That works ... turning off arrow immediately. |
now up on rebol.org | |
Graham 18-Nov-2005 [3265] | what would it take to have text flow automatically around a rectangular image in a area field? |
older newer | first last |