@@ -2074,37 +2074,34 @@ def set_handle_props(self, **handle_props):
20742074 self .update ()
20752075 self ._handle_props .update (handle_props )
20762076
2077- def _validate_state (self , value ):
2077+ def _validate_state (self , state ):
20782078 supported_state = [
20792079 key for key , value in self ._state_modifier_keys .items ()
20802080 if key != 'clear' and value != 'not-applicable'
20812081 ]
2082- if value not in supported_state :
2083- keys = ', ' .join (supported_state )
2084- raise ValueError ('Setting default state must be one of the '
2085- f'following: { keys } .' )
2082+ _api .check_in_list (supported_state , state = state )
20862083
2087- def add_state (self , value ):
2084+ def add_state (self , state ):
20882085 """
20892086 Add a state to define the widget's behavior. See the
20902087 `state_modifier_keys` parameters for details.
20912088
20922089 Parameters
20932090 ----------
2094- value : str
2091+ state : str
20952092 Must be a supported state of the selector. See the
20962093 `state_modifier_keys` parameters for details.
20972094
20982095 Raises
20992096 ------
21002097 ValueError
2101- When the value is not supported by the selector.
2098+ When the state is not supported by the selector.
21022099
21032100 """
2104- self ._validate_state (value )
2105- self ._state .add (value )
2101+ self ._validate_state (state )
2102+ self ._state .add (state )
21062103
2107- def remove_state (self , value ):
2104+ def remove_state (self , state ):
21082105 """
21092106 Remove a state to define the widget's behavior. See the
21102107 `state_modifier_keys` parameters for details.
@@ -2118,11 +2115,11 @@ def remove_state(self, value):
21182115 Raises
21192116 ------
21202117 ValueError
2121- When the value is not supported by the selector.
2118+ When the state is not supported by the selector.
21222119
21232120 """
2124- self ._validate_state (value )
2125- self ._state .remove (value )
2121+ self ._validate_state (state )
2122+ self ._state .remove (state )
21262123
21272124
21282125class SpanSelector (_SelectorWidget ):
@@ -2193,7 +2190,7 @@ def on_select(min: float, max: float) -> Any
21932190
21942191 state_modifier_keys : dict, optional
21952192 Keyboard modifiers which affect the widget's behavior. Values
2196- amend the defaults.
2193+ amend the defaults, which are:
21972194
21982195 - "clear": Clear the current shape, default: "escape".
21992196
@@ -2800,7 +2797,7 @@ def onselect(eclick: MouseEvent, erelease: MouseEvent)
28002797
28012798 state_modifier_keys : dict, optional
28022799 Keyboard modifiers which affect the widget's behavior. Values
2803- amend the defaults.
2800+ amend the defaults, which are:
28042801
28052802 - "move": Move the existing shape, default: no modifier.
28062803 - "clear": Clear the current shape, default: "escape".
@@ -2855,6 +2852,8 @@ class RectangleSelector(_SelectorWidget):
28552852 props=props)
28562853 >>> fig.show()
28572854
2855+ >>> selector.add_state('square')
2856+
28582857 See also: :doc:`/gallery/widgets/rectangle_selector`
28592858 """
28602859
0 commit comments