B4J Question [ABMaterial] Programmatically click a button?

MathiasM

Active Member
Licensed User
Hello

I have a UsernameInput and PasswordInput that are both ABMInput objects.
I want that if a user presses enter, it would 'submit the form'.

After some searching I found that the B4JS onkeyup event could probably help me, I could catch the keyup, check if it's an enter and then programatically 'push' the login button.

But after some testing, It seems to be possible to pass the button, but I see no way to push it.

Any insights on how would you 'tackle' this problem is greatly appreciated!
 

Cableguy

Expert
Licensed User
Longtime User
Hi mathias, A long time ago, I asked @Mashiane to "wrap" me a custom keyboard hook, the intentions was to be able to use key combos, but I guess that it can catch any key that is pressed. you can try and use it to call the Click event from an enter key press.
I'll try to find that thread and link it here
[EDIT] Found it
 
Upvote 0

Anser

Well-Known Member
Licensed User
Longtime User
Hello

I have a UsernameInput and PasswordInput that are both ABMInput objects.
I want that if a user presses enter, it would 'submit the form'.

I have not used B4JS. Here is what I have done

I have a Login Modal sheet where it has 2 ABMInput's ie one for the username and the other for the password, and also a Button for the Login/Submit. If the user hits Enter key, it will execute the Login Click

B4X:
Sub inpPassword_EnterPressed(value As String)
    btnLogin_Clicked("")
End Sub

Sub inpUserName_EnterPressed(value As String)
    Dim mymodal As ABMModalSheet = page.ModalSheet("login")
    Dim inpPassword As ABMInput = mymodal.Content.Component("inpPassword")
    inpPassword.SetFocus
End Sub
 
Upvote 0

MathiasM

Active Member
Licensed User
Thanks a lot. I'm going for Anser his solution because that more fits my needs I think.
Altough that keyboard hooking is also nice for a webapp.

I was unaware there was a _enterpressed event, is there documentation about the available events?

Thanks!
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
I was unaware there was a _enterpressed event, is there documentation about the available events?
With much luck, the upcoming book will uncover these (undocumented) events, properties and other such nuances..

Many such things to discover / uncover and utilize.

Thanks'
 
Upvote 0

Harris

Expert
Licensed User
Longtime User
For now, you can use sub + TAB to see the events on any component
Yes, seems to escape me at time of need, however... there are times when all are not exposed (for some reason not identified). No worry, we work it out and move happily along...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…