Main Board > Programming

Multi-Line SELECTOFFSET, SELECTLENGTH, SELECTTEXT$

(1/2) > >>

steezware:
In a multi-line control I want to grab the portion of the text that the user has selected.

For example...

* a multiline contains "Hello World Canada"
* the user double-taps on "World" and it shows as selected, highlighted
* they then click another control on the panel - or simply tab off the multiline
* in the logic that follows I attempt to grab the 'SelectOffset and 'SelectLength attributes ... but on leaving the multiline the users "World" selection is lost - no longer selected
* so what I really get in SelectOffset is 12, the zero-based offset for the "d" in "World"
* I need to get values 6 and 5This is in Nomads, under *Nomads object control, and I do not have any OnFocus or OnSelect logic tied to the multiline control either in the Nomads panel definition or in my UI class (although I have tried using them and signal-all-changes and signal-on-exit and everything else I could think of).

I can, of course, do a ML'SelectOffset=6 and ML'SelectLength=5 and manually highlight "World", so that works...

...but how to I grab "World" when the user selects it and leaves the multiline control?

Help? Thx!

Arno de Greef:
I see the same thing happen, however if I change the multi-line height to 2 (a multi-line multi-line  :D), the problem seems to disappear.

steezware:
Turns out that fetching 'SelectOffset and 'SelectLenght does work just fine, but the problem I am having turns out to be that the multiline control as it loses focus clears out the selection. So I need to figure out how to grab the offset/length when Nomads moves off the multiline before it loses focus?

I have tried 'Change and 'OnFocus and even thought maybe 'Validator or 'Formatter Nomads class functions would fire allow me to jump in and get the select offset/length, but no luck.

Or is there some multiline option/attribute that needs to be set to preserve the text selection when the multiline loses focus?

steezware:
Okay, putting this question/issue to rest. Arno was correct when he mentioned that making the multiline 2 rows high allowed for fetching 'SelectOffset, 'SelectLength and 'SelectText$.

So, I faked out my panel by making the multiline borderless and 2 lines high. I also messed around with making the font double-sized, which had an affect on fetching the offset and length.

Question to PxPlus is - why is it so difficult to fetch the offset and length of selected text in a multiline without work-arounds like making the control 2 rows high?

Len Vassos:
Thanks for the info, Scott.  We will review.

Navigation

[0] Message Index

[#] Next page

Go to full version