I’m having an hard time with the selectOnEnter property of a field.
In a table view I have a ItemCode field that requires to automatically select all the field content when the field get the focus so I have checked the selectOnEnter property and it works fine.
On the other hand I had to implement some keyboard shortcuts to automatically create a new row for commonly used item codes or PARTIAL item codes, example: CTRL-1 creates a new row and set the code to “P25_”, the user can then complete the code by typing the rest of it to “P25_50021”.
On the ItemCode field I have an onDataChange method that lookups the item description and price so when the keyboard shortcut is used I need to run the following code (I cant simply set the dataprovider value because the onDataChange then would not trigger):
if(_event)
{
var _shortcut = _event.getType()
var _sql = "SELECT cdshtc FROM shtc00f WHERE shtcmac = ? OR shtcpc = ? ORDER BY idshtc ASC"
var _ds = databaseManager.getDataSetByQuery('lfspa',_sql,[_shortcut,_shortcut],1)
if(_ds.getValue(1,1))
{
elements.fld_code.replaceSelectedText(_ds.getValue(1,1))
elements.fld_code.requestFocus(false)
}
}
It works fine but the whole field content is selected after the method is done and that is very annoying for the user.
I haven’t yet found a way to temporarily disable the field selectOnEnter property when running the shortcut method.
I have also tried to turn the property off and use an onFieldFocusGained method to select the whole text but that doesn’t work.
Any idea of how I could disable the selectOnEnter when running the shortcut method while keeping it active when the user simply enter the field?