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

[REBOL] Re: focus on a text field

From: carl::cybercraft::co::nz at: 24-Dec-2003 22:20

On 13-Jun-03, Greg Schwarz wrote:
> I have two text fields, one is for keyboard input, the other is used > for dynamic data. > When there is some dynamic data is inputed, the focus goes from one > text field to the othere and back again. > The problem is when it goes back to the keyboard input field, all > the text is hightlighted, and when you key the next char all the > text is replaced. I would like to know how to get the cursor back to > the end of the text your keying in? > view layout [ > dynamic: area 350x200 > keyboard: field 350x32 > ] > focus keyboard
Hi Greg, If you do a... probe first system/view at the console, you'll notice two words: highlight-start and highlight-end. They're words indexed to the start and end of highlighted text. So, one way to un-highlight text is to have... highlight-start: highlight-end in your code. To have it happen when a face is focused, you could modify the focus function like I have below. If you look at the source of focus, you'll see that the last thing it does is a... show face By inserting a word (focus-check) before that I've made it call a function before it shows the face, the function un-highlighting the text if the focus is on the keyboard face. So, here's the code... rebol [] focus-check: does [ if same? keyboard system/view/focal-face [ system/view/highlight-start: system/view/highlight-end ] ] ; Add 'focus-check word to 'focus function ;------------------------------------------ if 'focus-check <> first skip tail second :focus -3 [ insert skip tail second :focus -2 [focus-check] ] ; Test ;------ view layout [ dynamic: area 350x200 keyboard: field 350x32 "Test" field 350x32 "Normal field" do [focus keyboard] ] Hope that helps. -- Carl Read