Editline/Box/Table default states (OpenInsight 32-Bit)
At 01 NOV 2004 10:04:15AM Warren Auyong wrote:
How do I on focus to an EditLine/Box/Table would like to either:
Have all the data edit "selected" (as if doing a ctrl-a or dragging cursor select over all the data)
or
Start in overwrite edit mode, cursor at beginning of field.
TIA
At 01 NOV 2004 10:55AM Donald Bakke wrote:
Warren,
Use the SELECTION property with the parameter 1:@FM:64000 (or some other very large number) to pre-select all the text during the GOTFOCUS event.
dbakke@srpcs.com
At 01 NOV 2004 11:25AM dsig_at_sigafoos.org wrote:
This is what I use for tables .. something cameron came up with long ago as shown here
That little elf ApK found it for me again recently .. had completely forgotten about how it worked
dsig_at_sigafoos.org
Phone: 971-570-2005
At 01 NOV 2004 12:58PM Richard Hunt wrote:
Like Warren… I too am interested in knowing how to select all text in an editline and also have the cursor at the start of the selected text.
Using the selection property definately selects the text correctly… and it does NOT allow putting the cursor at the start of the selected text.
At 01 NOV 2004 02:08PM Warren Auyong wrote:
My guess is that there would be a 'style' for this behavior. The Visual FoxPro form designer has a setting for this. Unfortunately I don't have a copy of the 'style' insert so I can't determine that for certain.
At 03 NOV 2004 08:28AM Oystein Reigem wrote:
Warren
] Start in overwrite edit mode, cursor at beginning of field.
In a text editor or word processor one usually can change between an 'insert mode' and an 'overwrite mode'. Normally the Ins key is used to toggle between the two modes. In 'insert mode' new characters from the keyboard are inserted at the position of the caret. In 'overwrite mode' each character keyed in from the keyboard overwrites exactly one character at the caret position.
I cannot remember ever having seen this kind of 'overwrite mode' in OpenInsight. If somebody (like DSig) mentions 'overwrite mode' in connection with OpenInsight I think they normally mean a mode we meet all the time in edit tables. By default edit table cells at entry time have a mode where keying in a character clears the cell of its previous content, before the character is inserted and the cell switches to 'edit mode', which is like the 'insert mode' above.
Here's a simple scripted CHAR event handler that makes an edit control run in 'overwrite mode' the word processor way:
if VirtCode "" then
/* the key hit by the user is not a special key,
but the key for an ordinary visible character.
we want this character to overwrite
the exisisting character at the current position,
unless some text is selected in the control.
if something is selected we instead want the default behaviour,
which is to overwrite just the selected text */
Selection=Get_Property( CtrlEntId, "SELECTION" )
CaretPosition=Selection
/* new character has already been inserted.
delete one existing character */
Content=Get_Property( CtrlEntId, "DEFPROP" )
ContentCaretPosition, 1="
Void=Set_Property( CtrlEntId, "DEFPROP", Content )
Void=Set_Property( CtrlEntId, "SELECTION", Selection )
end
RETURN 0
There are a couple of possible issues, though:
- If the user has selected some text before hitting a character key, he will want the new character to overwrite the selected text and nothing more. My handler overwrites the next character too. I don't know of an easy solution for this problem. I first thought the solution would be to let the handler check the second part of the SELECTION property (SelectionLength=Selection), to see if some text is selected, but at the time the handler runs, the overwriting of the selection has already happened, and the selection length value has been reset to 0.
- The user might want to toggle between 'overwrite mode' and 'insert mode', e.g., with the Ins key. The solution is to store the state of the mode in a user defined property for the control, and let the CHAR handler watch for the Ins key being pressed (equate VK_INSERT$ to 45; if VirtCode=" and ScanCode=VK_INSERT$ then …etc…).
I have tested my handler in an edit box, but not in an edit table.
- Oystein -