Moving between elements on a page

28 views
Skip to first unread message

Chris Hopkins

unread,
Aug 15, 2017, 9:45:11 AM8/15/17
to gowebuitoolkit
Hi,
I've been building a toy application in gowut quite happily but hit a number of issues. The first:
I have a table where each cell is a text input box. The intention is that each cell contains a single rune. This is easy to do with the SetMaxLength function. 
What I can't figure out is that the behaviour I would like is that once the user has input their data into that box they are moved onto the next one. I'd like it so that the user can just enter their input without having to tab between input fields.

At a guess I would say this is not possible as you are needing to feedback to the browser to change the input location, but I thought I should ask before abandoning my preferred approach.

Before I forget, thanks very much for building this brilliant tool.

Regards

Chris

András Belicza

unread,
Aug 15, 2017, 9:53:44 AM8/15/17
to Chris Hopkins, gowebuitoolkit
Without trying, I'd say this is easily possible.

Register an event handler to the input boxes (e.g. for the ETypeChange even type), and in the event handler function, you can designate the component to transfer the focus to (after handling the current event).

Something like this:

tb := gwu.NewTextBox("")
tb.AddEHandlerFunc(func(e gwu.Event) {
e.SetFocusedComp(nextTextBox) // Pass the text box component you want to focus
}, gwu.ETypeChange)


Cheers.

Chris Hopkins

unread,
Aug 15, 2017, 10:40:21 AM8/15/17
to gowebuitoolkit, cbeho...@gmail.com
Thanks I've now got that working. I don't know why I didn't spot the term "Focused" in the documentation.

Much appreciated
Reply all
Reply to author
Forward
0 new messages