-
-
Notifications
You must be signed in to change notification settings - Fork 21.3k
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
Allow to focus individual tabs in TabBar
/TabContainer
#79104
Allow to focus individual tabs in TabBar
/TabContainer
#79104
Conversation
d1197b5
to
4be5836
Compare
Do you have a testing project available to test this pull request? If you do, please upload it here 🙂 |
Yeah I have, but it's very bare bones |
It does not work well with a controller: godot.windows.editor.dev.x86_64_6INRTJghI8.mp4Something like #63168 should be implemented probably. Also there doesn't seem to be any way to disable TabContainer focus (without using script), as they internal TabBar is focusable. I wonder if we should make it easier 🤔 It'd be useful when someone implements custom tab switching with keys different than left/right. |
Thanks, I will look into that.
I think it should be possible to use Tab key to switch focus away and I vaguely remember containers not letting focus outside was a thing at least in 3.x. |
4be5836
to
035c18e
Compare
Added the fix for the gamepads based on similar implementation in #63168 As for the changing focus from tab_container: in my case it is possible to move the focus away using Tab key and if the active Tab contains any focusable element I can easily navigate to it using up and down. It's not possible to move focus away from container but I'm pretty sure that logic is the same for all containers. |
Ok I wasn't clear. I meant making the container not focusable at all, not taking away focus. TabContainer is special, because it has an internal TabBar which itself can take focus and you don't have control over it. |
Alright. I think exposing the focus mode of the internal TabBar to the TabContainer as parameter should do a trick, then based on the needs everyone can setup Tabs and containers the way they want. |
035c18e
to
28844b7
Compare
Exposed methods for changing tabs in TabContainer (forgot about those earlier). |
28844b7
to
f8eea52
Compare
Focused tab in editor now uses accent color |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested locally (rebased on top of master
287f3aa), it works as expected.
Ok I'll be removing the rollover parameter, however I don't think it should stay off for the time being. I'm looking at the other Control nodes to compare the behaviors and the closest I found is the ItemList which doesn't rollover/loop the input. (Side note: ItemList appears to block the input if the next element is not selectable and/or disabled, which for me is a bug.) Maybe I'm missing something, @YuriSizov could you provide me an example of the class which has a rollover behavior active (and which can't be turned off)? |
Honestly, I just followed @YeldhamDev's feedback on this one, sorry 🙃 I'm fine with either option that makes sense. |
TabBar
/TabContainer
Alright. I'm finishing up the merge from master as there were some changes in editor_themes files. I should be done in few minutes. |
As you do, please amend the commit message to follow project's preferred style. The current title of the PR should be a good option. |
7eb2614
to
c5a6498
Compare
Now it should be fine. Let me know if I miss something... again. |
Your commit message is slightly wrong, seems like the old name is appended to the new one :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than the commit message, I think it's good now.
c5a6498
to
c769cd2
Compare
Commit message fixed - hopefully didn't break anything else. |
From the top of my head, |
I'm not aware of any GUI toolkit allowing for such a customization. |
BTW, a reminder that one can press Shift in order to get out of a focused |
doc/classes/TabBar.xml
Outdated
<method name="select_next_available"> | ||
<return type="bool" /> | ||
<description> | ||
Selects first available tab on the right from the currently selected. Returns [code]true[/code] if tab selection changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think UI mirroring will contradict this, as with a RTL layout the "next" tab will be to the left. So this may need to be rephrased to avoid this ambiguity (same in TabContainer). CC @bruvzg
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, in RTL layout, "next" is "left".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, in that case we have a bigger issue, as pressing left on keyboard or controller will go in opposite direction in RTL. I wasn't aware tabs are reordered in this way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Selects first available tab on the right from the currently selected. Returns [code]true[/code] if tab selection changed. | |
Selects the first available tab on the right from the currently selected. Returns [code]true[/code] if tab selection changed. |
Same below
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, in that case we have a bigger issue, as pressing left on keyboard or controller will go in opposite direction in RTL. I wasn't aware tabs are reordered in this way.
The fix should be pretty simple, you would need to check is_layout_rtl()
and use the opposite direction for the target tab. It would be fine to have a bit of code repetition between the next and the previous tab method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm having a little problem with rephrasing that sentence to be grammatically correct. How does
"Selects the first available tab with greater/lower index than the currently selected." sounds like? In case of lower index it sounds like the function will always select first tab ever so I'm not sure about this one.
c769cd2
to
f6694b2
Compare
f6694b2
to
bc5bfd0
Compare
I though I already submitted the change in doc description like a week ago. Sorry about the delay. |
Needs a rebase |
bc5bfd0
to
18811ac
Compare
Rebased and modified to be compatible with 2924bfd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
<method name="select_next_available"> | ||
<return type="bool" /> | ||
<description> | ||
Selects the first available tab with greater index than the currently selected. Returns [code]true[/code] if tab selection changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Selects the first available tab with greater index than the currently selected. Returns [code]true[/code] if tab selection changed. | |
Selects the first available tab with higher index than the currently selected. Returns [code]true[/code] if tab selection changed. |
Just potential nitpick, higher/lower are more complementary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I missed your review comment while merging my last batch.
<method name="select_next_available"> | ||
<return type="bool" /> | ||
<description> | ||
Selects the first available tab with greater index than the currently selected. Returns [code]true[/code] if tab selection changed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here in that case
Thanks! |
This is a refactor of #49928 compatible with stable releases of Godot 4, previous version was based on pre-alpha codebase. Since then few things changed: Tabs class was renamed to TabBar and TabContainer now internally uses TabBar.