question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SetFocus() change focus order by Tab

See original GitHub issue

Hello,

After applying SetFocus() to TextView the way of switching by Tab elements is changing. For example:

using Terminal.Gui;

namespace UICatalog {
	[ScenarioMetadata (Name: "FocusOrder", Description: "Demonstrate change of focus order after SetFocus()")]
	[ScenarioCategory ("Bug Repro")]
	class FocusOrder : Scenario {
	    class TextFrame : FrameView {
		    private TextView textField;
		    public TextFrame (string title) : base (title) {
			    textField = new TextView () {
				    X = 0,
				    Y = 0,
				    Width = Dim.Fill () - 15,
				    Height = Dim.Fill(),
				    ColorScheme = Colors.Dialog,
				    Text = "0"
			    };
			    var button1 = new Button ("Button 1…") {
				    X = Pos.Right(textField)+1,
				    Y = Pos.Top(textField),
				    Clicked = () => { Button1Handler();}
			    };
			    var button2 = new Button ("Button 2…") {
				    X = Pos.X(button1),
				    Y = Pos.Y(button1)+2,
				    Clicked = () => { Button2Handler();}
			    };
			    Add(textField, button1, button2);
		    }
		    public bool showMessage() {
			    var d =MessageBox.ErrorQuery("Error", "Error", "Ok");
			    this.SetFocus(textField);
			    return true;
		    }
		    private void Button1Handler() {
		    }
		    private void Button2Handler() {
			    showMessage();
		    }
	    }
		public override void Setup () {
		    var tf = new TextFrame ("Frame") {
			    X = 0,
			    Y = 0,
			    Width = Dim.Fill(),
			    Height = Dim.Fill() - 3
		    };
		    var button3 = new Button("Button 3") {
			    X = Pos.Percent(50) - 6,
			    Y = Pos.Bottom(tf) + 1,
		    };
		    Win.Add(tf, button3);
		}
	}
}

When focus changed by “Button 2” to TextView pressing Tab switch focus to “Button 3”. Estimated order is “Button 1”

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
aletcommented, Jul 27, 2020

Both working; I cloned BDisp:setfocus-order

1reaction
aletcommented, Jul 27, 2020

Thanks! The first variant works. The second generate exeption

Read more comments on GitHub >

github_iconTop Results From Across the Web

Control focus with tabindex - web.dev
Insert an element into the tab order #​​ To focus an element, press the Tab key or call the element's focus() method.
Read more >
Focus Next Element In Tab Index - javascript
The tab order of elements in a document is controlled by the tabindex attribute. If no value is set, the tabindex is effectively...
Read more >
How do I change the order the elements on my page are ...
Tab focus order will follow the DOM order of elements by default. If your issue is solely related to elements being out of...
Read more >
SetFocus function in Power Apps - Power Platform
The SetFocus function gives a control the input focus. The user's keystrokes are then received by that control, allowing them to type into...
Read more >
How to set focus on tab
Solved: Hi, i created a custom table with few fields. i decided those fields to 2 tabs. i was able to hide /...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found