B4J Question ABMInput events

DarkoT

Active Member
Licensed User
Hi Guys,

I will need help... It's possible to get some extra events for ABMinput component? I will need two option:
1. To raise event, when user press a special key (like F3 or Ctrl + "some key") and/or
2. when is user input ended (f.e. When input field lost focus AND input text is changed)...

How to capture this two events? I cannot find any solution...

Please, Help...
Regards, Darko
 

alwaysbusy

Expert
Licensed User
Longtime User
You can set this with these two properties. However, be aware that you will get al lot of traffic to your server, especially the Changed event. Use it carefully:

B4X:
Input.RaiseChangedEvent = True
Input.RaiseFocusEvent = True

events:
B4X:
Sub input_Changed(value As String)
    
End Sub

Sub input_LostFocus()
    
End Sub

Sub EventName_GotFocus()
    
End Sub

Alwaysbusy
 
Upvote 0

DarkoT

Active Member
Licensed User
You can set this with these two properties. However, be aware that you will get al lot of traffic to your server, especially the Changed event. Use it carefully:

B4X:
Input.RaiseChangedEvent = True
Input.RaiseFocusEvent = True

events:
B4X:
Sub input_Changed(value As String)
   
End Sub

Sub input_LostFocus()
   
End Sub

Sub EventName_GotFocus()
   
End Sub

Alwaysbusy

Hmm...

Yes, I know, that this two events exists... But - maybe - can you suggest me, which event should I use, to make control over input? Just to explain - user should input ID of material, I will check this ID and show the description of material (if material exists in DB)... It's will be useful when I will get event ONLY, when input is done to end...
Or - maybe should I build Button for each input to check input data? No, please, don’t suggest this... :)

Thank you for help...
Regards, DaT
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
You got Lostfocus, TabPressed and EnterPressed events. they are raised when someone leaves the input, pressed tab (to leave) or Enter.

And then you have the Changed event, which will be raised with every keystroke (not advised).

I mostly use the EnterPressed event (e.g. we have a Search input which when the user presses Enter, I run a query in the database and present only the ones that contain this text in a listbox).
 
Upvote 0

DarkoT

Active Member
Licensed User
You got Lostfocus, TabPressed and EnterPressed events. they are raised when someone leaves the input, pressed tab (to leave) or Enter.

And then you have the Changed event, which will be raised with every keystroke (not advised).

I mostly use the EnterPressed event (e.g. we have a Search input which when the user presses Enter, I run a query in the database and present only the ones that contain this text in a listbox).
Okey, clear... I will use Enter Pressed event and hope, this will be good solution...
Thank you, you deserve biiig coffee.. ;) :)

DaT
 
Upvote 0

alwaysbusy

Expert
Licensed User
Longtime User
You can cover all three in one if you want, but our users have no problem with only EnterPressed:

B4X:
Dim oldValue as String

Sub input_LostFocus()
   Dim input as ABMInput = page.Component("input")
   input_EnterPressed(input.Text)
End Sub

Sub input_TabPressed(target As String, value As String)
    input_EnterPressed(value)
End Sub

Sub input_EnterPressed(value As String)
   if Value <> oldValue then
       ' do your thing
      ...
   end if
   oldValue = Value
End Sub
 
Upvote 0

DarkoT

Active Member
Licensed User
You can cover all three in one if you want, but our users have no problem with only EnterPressed:

B4X:
Dim oldValue as String

Sub input_LostFocus()
   Dim input as ABMInput = page.Component("input")
   input_EnterPressed(input.Text)
End Sub

Sub input_TabPressed(target As String, value As String)
    input_EnterPressed(value)
End Sub

Sub input_EnterPressed(value As String)
   if Value <> oldValue then
       ' do your thing
      ...
   end if
   oldValue = Value
End Sub
Cooool!!!! That will be good solution... ;) Thnx... ;)
 
Upvote 0
Top