B4J Question How to set focus on web page - input field

DarkoT

Active Member
Licensed User
Hi to all,

Guys, need help… I try to build web application for some data input (from production stuff). It's possible to SET FOCUS to some input field and make field »active«? I want to use barcode scanner to capture some data and user will be able only to scan. I cannot figure out how to input data – not always to click with mouse in some input field…

It's possible to solve this?!

Tnx, Darko
 

DonManfred

Expert
Licensed User
Upvote 0

DarkoT

Active Member
Licensed User
Hi,
uf,... I'm not sure, I can understand this solution...
It's posible to do in source?
Like function "Inputfield.SetFocus" or ?

Sory, i'm still learning... ;) :)

Tnx, Darko
 
Upvote 0

alwaysbusy

Expert
Licensed User
it depends on how you are using it in B4J.

1. Pure html, add some javascript in the html file document ready event:
B4X:
$(document).ready(function() {
    $('#Username').focus();
});

2. If you are running a B4J jServer with WebSockets
B4X:
ws.eval("$('#Username').focus();", null)
ws.flush

3. ABMaterial
B4X:
Dim UserName as ABMInput = Page.Component("Username")
...
UserName.SetFocus

4. BANano
B4X:
Dim UserName as BANanoElement
UserName.Initialize("#Username")
UserName.RunMethod("focus", null)

And there are probably other ways too. We'll need some more info on what you've got to give a final answer.
 
Upvote 0

DarkoT

Active Member
Licensed User
Hi,
thank you for explanation... I'm using ABMaterial and I know that SetFocus function exists... But it's not working like I expected... When is focus send to input field, user need still to CLICK in field to start input data... Maybe should I ask in different way... What will be best solution for using barcode scanner on web application? Which control should I use, to activate automatically inserting the data with barcode scanner (imagine - I have 30 users in manufacturing company, which will use barcode scanner to START/STOP his working process - just scan barcode from workorder when users start to working and click to another barcode, when user want to stop his job)... In classical desktop application would be very “simple” – while focus in input field has always possibility for input (just typing – without mouse click before)…

Maybe any suggestion?

btw - i'm in love with B4J, Banano, AbMaterial - simple and clear to understand... ;)

Thanx, Darko
 
Upvote 0

DarkoT

Active Member
Licensed User
uf... Sory.. You have right... SetFocus working like expected.. It's only important, that focus is SET after page is finished (loaded)...

like this...


Dim btn3 As ABMButton
btn3.InitializeRaised(page, "Poslji", "mdi-image-palette", ABM.ICONALIGN_RIGHT, "Pošlji", "")
page.Cell(4,1).AddComponent(btn3)

page.Refresh ' IMPORTANT

' NEW, because we use ShowLoaderType=ABM.LOADER_TYPE_MANUAL
page.FinishedLoading 'IMPORTANT

Opravilo.SetFocus

Many thanx and have a nice day...
Regard, Darko
 
Upvote 0
Top