Initial cursor position in a TEXTBOX or GETBOX

114 views
Skip to first unread message

Ronaldo Geniais

unread,
Sep 1, 2021, 10:46:15 AM9/1/21
to Harbour Minigui


In a control (TEXTBOX or GETBOX), when the control receives focus with TAB, the cursor is automatically positioned at the initial position, but when the focus is done by the mouse, the positioning occurs according to the mouse pointer.
How is it possible to adjust this behavior, that is, that the positioning takes place in the initial position?

tigul...@gmail.com

unread,
Sep 2, 2021, 2:31:16 AM9/2/21
to Harbour Minigui
This is a very bad feature in HMG. I asked to correct it many years ago but with no result (First changed, then deleted the change)

You have to insert in line 2134 of h_events.prg these lines:

   *---------------------- FRANZ
            IF _HMG_aControlType [i] = 'GETBOX' .and. (Valtype(_HMG_aControlValue[i]) = "D" .or. Valtype(_HMG_aControlValue[i]) = "C")
               _PushKey(VK_HOME) && cursor at the beginning of the text or  _PushKey(VK_END)  && cursor at the end of the text
            ENDIF
 *---------------------- END FRANZ

Ciao
Franz



Auge & Ohr

unread,
Sep 2, 2021, 4:32:59 PM9/2/21
to Harbour Minigui
hi,

as i can say HMG does "mark" TEXTBOX when use TAB -Key but put "Caret" on END when use Mouse
you can use -1 to set Cursor to begin left before 1st Sign

   TXTform.TXTCtrl.CaretPos := nPosi

i use GOTFOCUS Event to "mark" hole TEXTBOX like Windows does

   hEditbox := GetControlHandle( "TXTCtrl", "TXTform" )
   SendMessage( hEditbox, EM_SETSEL, nPosi - 1, nPosi + LEN( cString ) )
   nStart := nPosi + 1

Jimmy

tigul...@gmail.com

unread,
Sep 3, 2021, 2:27:38 AM9/3/21
to Harbour Minigui
My solution is a workaround but I think this should be the standard behavior when you click on a Textbox or a GetBox. As everywhere is.
I think I have to use gotfocus event in my code for other special tasks.
Ciao
Franz


Auge & Ohr

unread,
Sep 3, 2021, 4:13:35 AM9/3/21
to Harbour Minigui
hi,

you can use more than 1 x ACTION in a Codeblock

   ONGOTFOCUS {|| Func1(), Func2(), Func3()} )

---

to use "_PushKey" is a Solution but why not use Windows Solution ?
HMG have

   <ParentWindowName>.<ControlName>.CaretPos := nCaretPosition
   <ParentWindowName>.<ControlName>.CaretPos  --> nCaretPosition

Note: if you set CaretPos to -1 moves the caret to the end of text and scrolls the text.

which is the same like my "pure" API Solution

Jimmy

tigul...@gmail.com

unread,
Sep 5, 2021, 10:41:32 AM9/5/21
to Harbour Minigui
I know but I think that "cursor at the end of text", must be a standard feature inside minigui core I don't have to repeat it in all my forms.
Ciao
Franz 

Reply all
Reply to author
Forward
0 new messages