Programmatically put text cursor in a control
ronecastro
Hey! I have a setvariable control wich answers to a keyboard event, in this case an 'Enter' keypress, where I copy the content to a text wave, used in a listbox control.
The problem is that when I press the key, it copies the content, but the text cursor disappears from the setvariable control, so I have to click on it or tab until the cursor comes back to it.
I'd like to keep the text cursor in the setvariable control after the copy, can I do that programmatically?
My code:
Function svAdiciona(svA)// : SetVariableControl
STRUCT WMSetVariableAction &svA
wave/T ListaSelecao = root:VarList:wListaSelecao
SVAR NomeEPICS = root:GlobalVariables:gNomeEPICS
switch( svA.eventCode )
case 1: // mouse up
break
case 2: // Enter key
InsertPoints (inf), 1, ListaSelecao
ListaSelecao[inf] = NomeEPICS
NomeEPICS = ""
ControlUpdate /W=CarregaDados svNomeEPICS
break
case -1: // control being killed
break
endswitch
return 0
End
STRUCT WMSetVariableAction &svA
wave/T ListaSelecao = root:VarList:wListaSelecao
SVAR NomeEPICS = root:GlobalVariables:gNomeEPICS
switch( svA.eventCode )
case 1: // mouse up
break
case 2: // Enter key
InsertPoints (inf), 1, ListaSelecao
ListaSelecao[inf] = NomeEPICS
NomeEPICS = ""
ControlUpdate /W=CarregaDados svNomeEPICS
break
case -1: // control being killed
break
endswitch
return 0
End
Thanks!
Right- the Enter key means, "accept the current contents of the SetVariable and stop editing". If you really want the SetVariable to be in edit mode after the Enter key, you can use SetVariable activate to programmatically put the control into edit mode. But it will select all the text when you do that.
February 28, 2019 at 03:14 pm - Permalink
That's exactly what I wanted, thank you! I just changed the ControlUpdate line to SetVariable/Z svNomeEPICS activate. It works as I need.
March 1, 2019 at 04:17 am - Permalink
That's great!
March 1, 2019 at 04:03 pm - Permalink