Dave Pearson
26df6aeb00
Tidy up the disabled snapshot test
2023-02-14 16:20:52 +00:00
Dave Pearson
b4f8a6b778
Add disabled snapshot test to the general snapshot tests
2023-02-14 15:53:45 +00:00
Dave Pearson
fbd871c3d7
Start a snapshot test for disabled widgets
...
Eventually this should likely have every user-interactive widget within it.
Perhaps every widget.
2023-02-14 15:52:52 +00:00
Dave Pearson
7763020f53
Move future import to after the module docstring
...
Looks like someone added this but placed it before the module docstring.
Fixing it as I notice it.
2023-02-14 15:00:57 +00:00
Dave Pearson
e26e75a9d1
Swap game_playable to use the simplified disable ability
2023-02-14 14:59:53 +00:00
Dave Pearson
5e0190c43f
Add unit tests for disabled property and pseudoclass
2023-02-14 14:47:57 +00:00
Dave Pearson
7c5020ddd3
Add a disabled keyword argument to the TextLog constructor
2023-02-14 13:27:44 +00:00
Dave Pearson
67b57d8a28
Add a disabled keyword argument to the DirectoryTree constructor
2023-02-14 13:14:52 +00:00
Dave Pearson
69af2bfd57
Add a disabled keyword argument to the Tree constructor
2023-02-14 13:11:44 +00:00
Dave Pearson
20aaf0f205
Add a disabled keyword argument to the ListView constructor
2023-02-14 13:04:44 +00:00
Dave Pearson
e1a60d9225
Add a disabled keyword argument to the Input constructor
2023-02-14 12:53:56 +00:00
Dave Pearson
9e4d4aae5e
Add a disabled keyword argument to the Switch constructor
2023-02-14 12:50:58 +00:00
Dave Pearson
3c8f464818
Update the snapshots
...
The disabled styling has changed slightly, and there is a snapshot test for
buttons which is now thrown off. This updates that.
2023-02-14 11:44:36 +00:00
Dave Pearson
c65278d038
Add default disabled styling for the whole application
2023-02-14 11:31:31 +00:00
Dave Pearson
cccf7afccb
Remove :disabled styling from the Button
...
This will move up to the App's default styles.
2023-02-14 11:30:55 +00:00
Dave Pearson
068aa07a5e
Only enable Enter and Leave if not disabled
...
Until now I was just removing all events that inherited from MouseEvent when
checking if an event was enabled for a given widget, in relation to the
widget itself being disabled. Enter and Leave also need to be taken into
account; they don't inherit from MouseEvent (they're more reactions to mouse
events) but should be handled too.
2023-02-14 11:28:31 +00:00
Dave Pearson
7c81247a95
Remove Button.watch_mouse_over
...
This isn't needed any more.
2023-02-14 11:22:25 +00:00
Dave Pearson
d27d9f81af
Only block mouse events if disabled, not if not focusable
2023-02-14 10:51:32 +00:00
Dave Pearson
674ee26b88
Add a docstring to watch_disabled
2023-02-14 10:40:17 +00:00
Dave Pearson
bff4334c5a
Merge branch 'main' into promote-disabled
2023-02-14 10:31:36 +00:00
Dave Pearson
c7990d990d
Add support for disabling a widget and all of its children
2023-02-14 09:56:09 +00:00
Will McGugan
ea74ca7725
Merge pull request #1778 from Textualize/screens-redux
...
implements screens view
2023-02-14 09:55:07 +00:00
Will McGugan
2db2ae1b52
property docstring
2023-02-14 09:34:04 +00:00
Will McGugan
6f1abe849f
fix reference
2023-02-13 17:30:53 +00:00
Will McGugan
497503fa3a
docstrings
2023-02-13 17:14:52 +00:00
Dave Pearson
ea8470ee7a
Stop mouse events going to a widget that can't receive focus right now
2023-02-13 16:55:08 +00:00
Dave Pearson
525455bf76
Bring the focus_chain docstring in line with out newer guidelines
2023-02-13 16:19:38 +00:00
Dave Pearson
d148dd6237
Swap _reset_focus over to focsuable (from can_focus)
2023-02-13 16:14:13 +00:00
Dave Pearson
813c89c1ef
Swap _forward_event over to focsuable (from can_focus)
2023-02-13 16:12:28 +00:00
Dave Pearson
850c140a05
Swap set_focus over to checking focusable
2023-02-13 16:10:28 +00:00
Will McGugan
2a8b099f33
fix
2023-02-13 15:47:38 +00:00
Dave Pearson
0171ad7c85
Build the focus chain from focusable widgets
...
Rather than it being about widgets where `can_focus` is `True`, have it be
about widgets that are currently able to receive focus. Before this change
widgets with a positive `can_focus` but which were disabled would still end
up in the chain.
2023-02-13 15:44:02 +00:00
Dave Pearson
8379945b60
Remove commented out code from Button
...
Some hangover from the work to migrate `disabled` out of `Button` and into
`Widget`, that I forgot to remove.
2023-02-13 15:43:40 +00:00
Dave Pearson
bf1188c712
Merge branch 'promote-disabled' of github.com:davep/textual into promote-disabled
2023-02-13 15:43:10 +00:00
Dave Pearson
500458e5f3
Add a focusable property
...
We want to maintain `can_focus` as "this is a thing that can, at some point,
receive focus, assuming it isn't disabled". So `can_focus` is now very much
about the ability to receive focus at all.
The new `focusable` property becomes about "can this widget receive focus
right now?".
[This is a rewording of a previous commit -- I get the wrong thing]
2023-02-13 15:40:18 +00:00
Dave Pearson
14f83a0a4a
Remove commented out code from Button
...
Some hangover from the work to migrate `disabled` out of `Button` and into
`Widget`, that I forgot to remove.
2023-02-13 15:39:19 +00:00
Will McGugan
4cdc139853
name fix
2023-02-13 15:12:02 +00:00
Dave Pearson
682c4de06d
Remove unnecessary comment
...
Don't use comments as version control! Or, really, I don't need this note to
self any more about the code as it's being handled elsewhere.
2023-02-13 15:11:33 +00:00
Will McGugan
c7e5ac14fb
rename
2023-02-13 15:10:32 +00:00
Will McGugan
6b5015b266
mass renaming
2023-02-13 15:09:40 +00:00
Will McGugan
e75024ef58
nanoid
2023-02-13 15:06:26 +00:00
Will McGugan
c6ce34d009
removed deprecate view object
2023-02-13 14:49:39 +00:00
Will McGugan
a845016264
no longer required
2023-02-13 14:41:17 +00:00
Dave Pearson
bbdc70a620
Move the main handling of disabled up to Widget
...
There's still a bit to do here, but this migrates the main work up to the
`Widget`. At this point `Button` is pretty much built expressed as a
function of what `Widget` provides in terms of things being disabled.
Focus can still move into disabled controls (or in this case right now, into
a disabled `Button`). The next step is to add something that works alongside
`can_focus` to say if a control is currently capable of receiving focus (in
other words, it's `not disabled and can_focus`).
2023-02-13 14:28:10 +00:00
Dave Pearson
1097fb267d
Set the initial disabled state later in __init__
...
I was going too early with setting this; it needs to happen after pretty
much everything else is set up *and* after the super's __init__ has been
called.
2023-02-13 14:25:40 +00:00
Dave Pearson
d37895dfdd
Convert some app.update_styles calls into _update_styles calls
2023-02-13 14:23:20 +00:00
Dave Pearson
3707f80aa4
Move duplicate safe calls to update_styles into a single method
...
It's done as an internal, but can be called from child classes of course.
This is intended to be a single central method of asking the app to update
styles while also not caring if there is no active app available just yet.
2023-02-13 14:19:36 +00:00
Will McGugan
204c048e2b
children_view test
2023-02-13 13:39:09 +00:00
Dave Pearson
821a6ff7c1
Simplify the default for disabled on a Widget
...
There was no need to default to None and then convert to a bool, defaulting
to False is just fine.
2023-02-13 13:09:12 +00:00
Dave Pearson
d3104a92c9
Add disabled as a widget construction keyword argument
2023-02-13 13:05:18 +00:00