On 14/08/2013 at 15:47, xxxxxxxx wrote:
This is the solution I came up with for getting the selected text in a GeDialog() text box:
LONG myDialog::Message(const BaseContainer &msg, BaseContainer &result)
{
String text;
this->GetString (1001, text); //Get the text in the text box (1001 is the id for the edit text gizmo)
if(GetString(1001, text)) //If the edit text gizmo is not empty
{
//The cStart value is the position in the text where you started dragging(highligthing the text)
//The cPos value is the current position the cursor is in
//The range of selected text characters = cPos-cStart
BaseContainer blockStart(BFM_EDITFIELD_GETBLOCKSTART);
GeData bs = SendMessage(1001, blockStart);
LONG cStart = bs.GetLong();
BaseContainer cursorPos(BFM_EDITFIELD_GETCURSORPOS);
GeData cp = SendMessage(1001, cursorPos);
LONG cPos = cp.GetLong();
LONG numSelected = cPos-cStart; //The number of selected text characters
String selected = "";
if(numSelected >= 1) //If the user selected the text from left to right
{
GePrint("Start: " + LongToString(cStart) + " " + "Pos: " + LongToString(cPos) + " " + "NumSel: " + LongToString(numSelected));
for (LONG i=0; i<numSelected; i++)
{
String s = text.SubStr(cStart+i, 1);
String combine = selected.operator+=(s); //Adds the current char to the "selected" string variable
}
}
GePrint(selected);
}
return GeDialog::Message(msg,result);
}
Seems to work pretty well.
But I'm always interested in seeing how other people solve things. I learn new things that way.
So if you figured out another way to so it. I'd love to see what you came up with.
-ScottA