Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explicitly place cursor in field so it is ready to begin typing? #132

Open
MostHated opened this issue Jun 13, 2019 · 2 comments
Open

Explicitly place cursor in field so it is ready to begin typing? #132

MostHated opened this issue Jun 13, 2019 · 2 comments

Comments

@MostHated
Copy link

MostHated commented Jun 13, 2019

Heya,
I am trying to find a way to make it so that upon opening the application, or opening specific windows the cursor is placed explicitly within a field and you can begin typing in it without having to click on it first, but I have yet to find the magic combination to make it work.

I tried to see if this might work, but no such luck:

	settingsFrame.OnActive(func(active bool) { // ------------------------------------- The parent container 
		tokenEdit.ProcessEvent(ui.Event{Type: ui.EventKey, Key: term.MouseLeft}) // ----- Edit field 

		//(func() {
		//	ui.PutEvent(ui.Event{Type: ui.EventKey, Key: term.MouseLeft})
		//})()
	})

	settingsFrame.SetActive(true)

I tried to see if using term.KeyTab might work, but it tabs to the menu instead of within the current frame.

What could work is if there were identifiers/number order to the tabstops, and I could specify a target for the tab.

___Main Window__________________________________________________________________
   Frame for Menu           | Frame for contents - frame2                       |
    ______________________  |    _____________________________________________  |
   | MenuItem1 - TabId0   | |   |Frame for Textfield                          | |
   | MenuItem1 - TabId1   | |   |                                             | |
   | MenuItem2 - TabId2   | |   | Label : ==== TextField ====== - TabId5      | |
   | MenuItem3 - TabId3   | |   |_____________________________________________| |
   | MenuItem4 - TabId4   | |                                                   |
   |______________________| |                                                   |
____________________________|___________________________________________________|

// --- onVisible, or possible onActivate? ---------------------------------------------------
frame2.onVisible(true){
    ui.PutEvent(ui.Event{Type: ui.EventKey, Key: term.TabKey, Target: TabId5 })
}   

Something like the above, so upon frame2 becoming available it will automatically place the cursor into the text field so that someone can start typing without having to click, tab, etc manually, allowing much more fluid movement and less need of the mouse?

I see that there is a Target within the event struct, so I tried:

    //--- tokenEdit is the edit field I am trying to make the cursor go to currently in my testing
    ui.PutEvent(ui.Event{Type: ui.EventKey, Key: term.MouseLeft, Target: tokenEdit}) 

That didn't seem to work though.

@VladimirMarkelov
Copy link
Owner

Have you tried something like ui.ActivateControl(window, tokenEdit)? where window is your Window that contains frame frame2 or settingsFrame?

@MostHated
Copy link
Author

It seems to move the cursor there, but it wont let you type unless you physically click in the edit field. If you tab to it though, as soon as it lands on the field you can start typing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants