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

fields and keyboard

 [1/22] from: riusa:email:it at: 29-Jan-2002 15:14


Hi to everyone! I'm a almost new Rebol user, and I wish some inform about keyboard control in "field" of layout/view. I wish to create a routine to convert to uppercase everything typed inside the field. I tried with "feel"->engage, but I cannot write anything inside the field. So I tried with "feel"->detect... I wrote inside the field, but "detect" didn't detect keypress!!! (windows 2000) I found a top-level script to create a new event handler for the layout view, but the fuction is recalled before the key is written in the field... result? I have the most recent key never converted: Ab ABc ABCd (and so on...) Can I detect when the user enter in the field, and when he exits (mouse or tab or enter key)? Can I detect every keypress, but letting the control of the cursor to the user (a mix of "engage" and "detect"). Thank you! Bye! -- Prendi GRATIS l'email universale che... risparmia: http://www.email.it/f Sponsor: Più siamo, meno paghiamo: unisciti a un gruppo d’acquisto di bid.it! Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=232&d=29-1

 [2/22] from: brett:codeconscious at: 30-Jan-2002 18:32


Hi!
> I'm a almost new Rebol user, and I wish some inform about keyboard > control in "field" of layout/view. > > I wish to create a routine to convert to uppercase everything typed > inside the field.
Seems totally reasonable. I've tried for half an hour to work out to solve it. But I cannot. Maybe I'm missing something really simple, but I can't find a simple way to extend the existing field behaviour with the uppercase behaviour you want. Any one else got some ideas?!! Brett.

 [3/22] from: sunandadh:aol at: 30-Jan-2002 4:10


> > I wish to create a routine to convert to uppercase everything typed > > inside the field.
This is not automatic (you have to exit the field before it folds), but it may be enough. rebol [] fold-field: func [face /upper /lower] [ if upper [face/text: uppercase face/text] if lower [face/text: lowercase face/text] show face ] unview/all view layout [field1: field [fold-field/upper face] field2: field [fold-field/lower face] ] Sunanda.

 [4/22] from: riusa:email:it at: 30-Jan-2002 12:10


Thank you! This is a simple but good idea! This solution reminds me of another question: I didn't know the code following a "field" was executed as soon as the user left the field... where can I find all the "default" actions executed by a object/view? (buttons: "click button" then "exec the code"; "exit field" then "exec the code"; other actions/reactions? ) thank you!
> > > I wish to create a routine to convert to uppercase everything
typed
> > > inside the field. > > This is not automatic (you have to exit the field before it folds),
but it
> may be enough. > rebol []
<<quoted lines omitted: 9>>
> Sunanda. > --
-- Prendi GRATIS l'email universale che... risparmia: http://www.email.it/f Sponsor: Obiettivo Laurea? vuoi migliorare il tuo metodo di studio? Per informazioni Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=213&d=30-1

 [5/22] from: rotenca:telvia:it at: 30-Jan-2002 14:38


Hi Brett
> But I cannot. Maybe I'm missing something really simple, but I can't find > a simple way to extend the existing field behaviour with the uppercase > behaviour you want. > > Any one else got some ideas?!!
This is my hack (another way is to modify system/ctx-text/ctx-edit): upper-eng: func [face act event] bind [ switch act [ down [ either not-equal? face view*/focal-face [ focus face view*/caret: offset-to-caret face event/offset ] [ view*/highlight-start: view*/highlight-end: none view*/caret: offset-to-caret face event/offset ] show face ] over [ if not-equal? view*/caret offset-to-caret face event/offset [ if not view*/highlight-start [view*/highlight-start: view*/caret] view*/highlight-end: view*/caret: offset-to-caret face event/offset show face ] ] key [ edit-text face make object! [ ;modified part of engage shift: event/shift control: event/control key: either char? event/key [first uppercase form event/key][event/key] ] get in face 'action ] ] ] in system/words/ctx-text 'self l: layout [f: field "" feel [engage: :upper-eng]] view l --- Ciao Romano

 [6/22] from: g:santilli:tiscalinet:it at: 30-Jan-2002 20:48


Hello Brett! On 30-Gen-02, you wrote: BH> Any one else got some ideas?!! Creating a custom /engage (copying for the one of Field) that calls a custom edit-text (copying from ctx-text/edit-text). You'll just need to uppercase the character before inserting into the string. Maybe you could just patch ctx-text/edit-text to check for a flag in the face and then act accordingly... Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [7/22] from: brett:codeconscious at: 31-Jan-2002 9:44


Thanks Romano and Gabriele, You confimed my suspicision. As the ctx-text/edit feel object is now, there is no simple way to extend the functionality. Adding a flag to the face is a good idea. Maybe there should be some special user-defined editing function that can be called for easy extended functionality. Brett.

 [8/22] from: rotenca:telvia:it at: 31-Jan-2002 1:37


Hi Brett,
> You confimed my suspicision. As the ctx-text/edit feel object is now, there > is no simple way to extend the functionality. Adding a flag to the face is a > good idea. > > Maybe there should be some special user-defined editing function that can > be called for easy extended functionality.
A little less hack (i use face/user-data for flag): ctx-text/insert-char: func [face char] bind [ delete-selected-text if not same? head face/text head view*/caret [view*/caret: at face/text index? view*/caret] face/dirty?: true ;---changed part--- view*/caret: insert view*/caret either all [ string? face/user-data face/user-data = "--upper--" ][ first uppercase form char ][ char ] ] in ctx-text 'self l: layout [f: field "" with [user-data: "--upper--"]] view l --- Ciao Romano

 [9/22] from: brett:codeconscious at: 31-Jan-2002 12:22


Hi Romano, Combining your script, Gabriele's flag idea and my own style addition yields: ctx-text/insert-char: func [face char] bind [ delete-selected-text if not same? head face/text head view*/caret [ view*/caret: at face/text index? view*/caret ] face/dirty?: true ;---changed part--- view*/caret: insert view*/caret either flag-face? face UPPERCASE [ first uppercase form char][char] ] in ctx-text 'self l: layout [ style upper-case-field field with [ append init [flag-face self UPPERCASE] ] f: upper-case-field "" ] view l

 [10/22] from: riusa:email:it at: 31-Jan-2002 9:10


Hi, can someone explain me what is exactly ctx-text? I tried using ? ctx-text but Rebol shown me a lot of code! ===========================================
> Thanks Romano and Gabriele, > > You confimed my suspicision. As the ctx-text/edit feel object is now,
there
> is no simple way to extend the functionality. Adding a flag to the
face is a
> good idea. > > Maybe there should be some special user-defined editing function that
can
> be called for easy extended functionality. > > Brett.
-- Prendi GRATIS l'email universale che... risparmia: http://www.email.it/f Sponsor: Più siamo, meno paghiamo: unisciti a un gruppo d’acquisto di bid.it! Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=232&d=31-1

 [11/22] from: brett:codeconscious at: 31-Jan-2002 20:30


Hi,
> Hi, can someone explain me what is exactly ctx-text? > I tried using "? ctx-text" but Rebol shown me a lot of > code!
Short answer 1: It is a lot of code! :) Short answer 2: It holds a lot of the functions that FIELD, AREA, TEXT, H1, H2, etc. need. Longer answer: You can build VID programs without knowing about it. ctx-text is an object! which holds some words, some objects and a lot of functions. All these things are grouped in the object ctx-text because they relate to text handling. For example, these functions and objects work together to give the ability to copy text from a View window to the clipboard. Like this: view layout [text {Highlight this text with you mouse and copy it to the clipboard using ctrl-c.}] If I deliberately "cut the link" to ctx-text - see what happens: view layout [text "Try to copy this text now." with [feel: none]] Normally this prints true: layout [text-object: text "Some text"] print same? text-object/feel ctx-text/swipe So the summary is VID styles use ctx-text to handle keystrokes, and other text handling. Brett.

 [12/22] from: cyphre:seznam:cz at: 31-Jan-2002 10:47


Hi, I didn't read all about this thread but if I understand it here is another solution: stylize/master [ upper-case-field: field with [ feel: make feel [ redraw: func first :redraw append second :redraw [if act = 'show [face/text: uppercase face/text]] ] ] ] view layout [ upper-case-field ] regards Cyphre

 [13/22] from: riusa:email:it at: 31-Jan-2002 11:23


Thanks a lot!
> Hi, > > > Hi, can someone explain me what is exactly ctx-text? > > I tried using "? ctx-text" but Rebol shown me a lot of > > code! > > Short answer 1: It is a lot of code! :) > > Short answer 2: It holds a lot of the functions that FIELD, AREA,
TEXT, H1,
> H2, etc. need. > > Longer answer: > > You can build VID programs without knowing about it. > > ctx-text is an object! which holds some words, some objects and a lot
of
> functions. > All these things are grouped in the object ctx-text because they
relate to
> text handling. > For example, these functions and objects work together to give the
ability
> to copy text from a View window to the clipboard. Like this: > view layout [text {Highlight this text with
<<quoted lines omitted: 6>>
> print same? text-object/feel ctx-text/swipe > So the summary is VID styles use ctx-text to handle keystrokes, and
other
> text handling. > > Brett. > > -- > To unsubscribe from this list, please send an email to > [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes. >
++++++++++++++++++++++++++++++++++++++++++++ Alessandro Manotti Presidente dell'Associazione "RIUSA" Sito web: http://riusa.apritisesamo.net email: [riusa--email--it] mailing-list: [riusa-ml--yahoogroups--com] Telefono: 347.63.43.231 -- Prendi GRATIS l'email universale che... risparmia: http://www.email.it/f Sponsor: Più siamo, meno paghiamo: unisciti a un gruppo d’acquisto di bid.it! Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=232&d=31-1

 [14/22] from: brett:codeconscious at: 31-Jan-2002 22:31


Ooo I like that. :) Brett. ----- Original Message ----- From: "Cyphre" <[cyphre--seznam--cz]> To: <[rebol-list--rebol--com]> Sent: Thursday, January 31, 2002 8:47 PM Subject: [REBOL] Re: fields and keyboard Hi, I didn't read all about this thread but if I understand it here is another solution: stylize/master [ upper-case-field: field with [ feel: make feel [ redraw: func first :redraw append second :redraw [if act = 'show [face/text: uppercase face/text]] ] ] ] view layout [ upper-case-field ] regards Cyphre

 [15/22] from: riusa:email:it at: 31-Jan-2002 13:02


What is that?! I'm sorry, I still find some problems to understand Rebol code. Can you explain me exactly what that program do? How does it function? Thanks for your patience! =======================================================>
> Hi, > > I didn't read all about this thread but if I understand it here is
another
> solution: > > stylize/master [ > upper-case-field: field with [ > feel: make feel [ > redraw: func first :redraw append second :redraw [if act
= 'show
> [face/text: uppercase face/text]] > ]
<<quoted lines omitted: 17>>
> > > > > > You confimed my suspicision. As the ctx-text/edit feel object is
now,
> > there > > > is no simple way to extend the functionality. Adding a flag to the > > face is a > > > good idea. > > > > > > Maybe there should be some special user-defined editing function
that
> > can > > > be called for easy extended functionality.
<<quoted lines omitted: 6>>
> > -- > > Prendi GRATIS l'email universale che... risparmia:
http://www.email.it/f
> > > > Sponsor:
<<quoted lines omitted: 16>>
> [rebol-request--rebol--com] with "unsubscribe" in the > subject, without the quotes.
++++++++++++++++++++++++++++++++++++++++++++ Alessandro Manotti Presidente dell'Associazione "RIUSA" Sito web: http://riusa.apritisesamo.net email: [riusa--email--it] mailing-list: [riusa-ml--yahoogroups--com] Telefono: 347.63.43.231 -- Prendi GRATIS l'email universale che... risparmia: http://www.email.it/f Sponsor: Lavori e non puoi frequentare? Scegli tra 400 Corsi di Laurea e 120 Master on-line. Clicca qui: http://adv.email.it/cgi-bin/foclick.cgi?mid=60&d=31-1

 [16/22] from: g:santilli:tiscalinet:it at: 31-Jan-2002 15:15


Hello Romano! On 31-Gen-02, you wrote: RT> A little less hack (i use face/user-data for flag): Why not FLAG-FACE and FLAG-FACE? ? Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [17/22] from: g:santilli:tiscalinet:it at: 31-Jan-2002 15:10


Hello Brett! On 31-Gen-02, you wrote: BH> Maybe there should be some special user-defined editing BH> function that can be called for easy extended functionality. What about changing just /engage and placing a function between edit-text and the event? I.e. change the line: key [edit-text face event get in face 'action] to something like: key [edit-text face face/pre-process event get in face 'action] or you could: key [ if not all [in face 'custom-edit face/custom-edit event] [ edit-text face event get in face 'action ] ] Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

 [18/22] from: rotenca:telvia:it at: 31-Jan-2002 15:04


Hi, Brett stylize/master [ upper-case-field: field with [ feel: make feel [ redraw: func first :redraw append second :redraw [if act = 'show [face/text: uppercase face/text]] ] ] ]
> Ooo I like that. :)
Is a taste question, but... If the string is short and the window is not complex, not in a 200kb string or in a 200 faces window (i have a program of mine which uses this sort of monster, you can think at a spreadsheet). In general, it is a waste of time: Redraw slows window rendering and the function continues to uppercase the already uppercased chars at every show. A little thing: [face/text: uppercase face/text] can be [uppercase face/text] --- Ciao Romano

 [19/22] from: rotenca:telvia:it at: 31-Jan-2002 16:24


I left the work to Brett... :-) --- Ciao Romano

 [20/22] from: cyphre::seznam::cz at: 31-Jan-2002 17:11


Hi Romano, ----- Original Message ----- From: "Romano Paolo Tenca" <[rotenca--telvia--it]> To: <[rebol-list--rebol--com]> Sent: Thursday, January 31, 2002 3:04 PM Subject: [REBOL] Re: fields and keyboard
> Hi, Brett > stylize/master [
<<quoted lines omitted: 8>>
> Is a taste question, but... > If the string is short and the window is not complex, not in a 200kb
string or
> in a 200 faces window (i have a program of mine which uses this sort of > monster, you can think at a spreadsheet).
fielda aren't usually used for 200Kb strings ;-)
> In general, it is a waste of time: Redraw slows window rendering and the > function continues to uppercase the already uppercased chars at every
show.
'show event is triggered usually only for active field and when user hit any key...so where is the slowdown??? moreover:
>> st: now/time/precise loop 10000 [uppercase random "593428pf9rhtepowfh9
pw3r8fhp3wghw3rijwpoihpg"] now/time/precise - st == 0:00:00.09 ;on my celeron 533Mhz so where is the problem with speed? ;-) regards, Cyphre

 [21/22] from: rotenca:telvia:it at: 31-Jan-2002 17:13


Hi Gabriele,
> I.e. change the line: > > key [edit-text face event get in face 'action] > > to something like: > > key [edit-text face face/pre-process event get in face 'action]
I am not able to change an event field. Have i missed something or you are thinking to an hack like my first one? --- Ciao Romano

 [22/22] from: g:santilli:tiscalinet:it at: 31-Jan-2002 19:25


Hello Romano! On 31-Gen-02, you wrote: RT> I am not able to change an event field. Have i missed RT> something or you are thinking to an hack like my first one? You're right, the only option is the second I proposed. Regards, Gabriele. -- Gabriele Santilli <[giesse--writeme--com]> - Amigan - REBOL programmer Amiga Group Italia sez. L'Aquila -- http://www.amyresource.it/AGI/

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted