1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

B4J Question [ABMaterial] Programmatically click a button?

Discussion in 'B4J Questions' started by MathiasM, May 24, 2019.

  1. MathiasM

    MathiasM Member Licensed User


    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!
  2. Cableguy

    Cableguy Expert Licensed 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
    MathiasM likes this.
  3. Anser

    Anser Well-Known Member Licensed User

    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

    Sub inpPassword_EnterPressed(value As String)
    End Sub

    Sub inpUserName_EnterPressed(value As String)
    Dim mymodal As ABMModalSheet = page.ModalSheet("login")
    Dim inpPassword As ABMInput = mymodal.Content.Component("inpPassword")
    End Sub
    MathiasM and Cableguy like this.
  4. MathiasM

    MathiasM 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?

  5. Harris

    Harris Well-Known Member Licensed User

    With much luck, the upcoming book will uncover these (undocumented) events, properties and other such nuances..

    Many such things to discover / uncover and utilize.

    Cableguy and alwaysbusy like this.
  6. alwaysbusy

    alwaysbusy Expert Licensed User

    For now, you can use sub + TAB to see the events on any component
    MathiasM and Harris like this.
  7. Harris

    Harris Well-Known Member Licensed User

    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...
    Cableguy likes this.
  8. MathiasM

    MathiasM Member Licensed User

    Thanks, that's easy if you know it :)
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice