Page 1 of 1

EditorGadget - determine selection

Posted: Mon Nov 17, 2025 7:36 pm
by ZX80
Good day to all.

Maybe someone has already encountered a similar problem ? Maybe someone has already solved this ?
I have an editor gadget. The user selects one line, several lines, or all lines. It doesn't matter if it was a mouse or another method (keyboard). These questions interest me. That is, when a button is pressed, I want to know whether all the text, several lines, or just one line is selected. Maybe even just part of a line. I would like to know the line numbers that were marked. All, even partially selected ones.

Thank you in advance for your answers.

Re: EditorGadget - determine selection

Posted: Tue Nov 18, 2025 5:39 pm
by Axolotl
You should really try the forum search first.
On Windows like this, on others search for Shardiks codes.

Code: Select all

Define Range.CHARRANGE
SendMessage_(GadgetID(Gadget), #EM_EXGETSEL, 0, @Range)  ; no return value, wParam not used  
;
; Range\cpMin ... Character position index immediately preceding the first character in the range. 
; Range\cpMax ... Character position immediately following the last character in the range. 
; 
; Get the Selected Text ..... 
;
;   Text$ = Space(Range\cpMax - Range\cpMin)  ; alloc string memory 
;   SendMessage_(GadgetID(Gadget), #EM_GETSELTEXT, 0, @Text$) 

Re: EditorGadget - determine selection

Posted: Thu Nov 20, 2025 9:02 am
by ZX80
Axolotl, thank you !

This is what is needed.