File tree 3 files changed +22
-1
lines changed
3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,11 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
23
23
- Added ` Widget.scrollable_container ` property
24
24
- Added ` Widget.select_all `
25
25
- Added ` Region.bottom_right_inclusive `
26
+ - Added double click to select, triple click to select all in container
27
+ - Added arbitrary text selection
28
+ - Added Widget.ALLOW_SELECT classvar for a per-widget switch to disable text selection
29
+ - Added Widget.allow_select method for programmatic control of text selection
30
+ - Added App.ALLOW_SELECT for a global switch to disable text selection
26
31
27
32
### Fixed
28
33
Original file line number Diff line number Diff line change @@ -396,6 +396,12 @@ class MyApp(App[None]):
396
396
Setting to `None` or `""` disables auto focus.
397
397
"""
398
398
399
+ ALLOW_SELECT : ClassVar [bool ] = True
400
+ """A switch to toggle arbitrary text selection for the app.
401
+
402
+ Note that this doesn't apply to Input and TextArea which have builtin support for selection.
403
+ """
404
+
399
405
_BASE_PATH : str | None = None
400
406
CSS_PATH : ClassVar [CSSPathType | None ] = None
401
407
"""File paths to load CSS from."""
Original file line number Diff line number Diff line change @@ -511,6 +511,11 @@ def is_active(self) -> bool:
511
511
except Exception :
512
512
return False
513
513
514
+ @property
515
+ def allow_select (self ) -> bool :
516
+ """Check if this widget permits text selection."""
517
+ return self .ALLOW_SELECT
518
+
514
519
def render (self ) -> RenderableType :
515
520
"""Render method inherited from widget, used to render the screen's background.
516
521
@@ -1520,7 +1525,12 @@ def _forward_event(self, event: events.Event) -> None:
1520
1525
select_widget , select_offset = self .get_widget_and_offset_at (
1521
1526
event .screen_x , event .screen_y
1522
1527
)
1523
- if select_widget is not None and select_widget .allow_select :
1528
+ if (
1529
+ select_widget is not None
1530
+ and select_widget .allow_select
1531
+ and self .screen .allow_select
1532
+ and self .app .ALLOW_SELECT
1533
+ ):
1524
1534
self ._selecting = True
1525
1535
if select_widget is not None and select_offset is not None :
1526
1536
self ._select_start = (
You can’t perform that action at this time.
0 commit comments