We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4ca8a52 commit f1f73d3Copy full SHA for f1f73d3
commands2/button/trigger.py
@@ -122,6 +122,26 @@ def _():
122
123
return self
124
125
+ def onChange(self, command: Command) -> Self:
126
+ """
127
+ Starts the command when the condition changes.
128
+
129
+ :param command: the command t start
130
+ :returns: this trigger, so calls can be chained
131
132
+ self._last_pressed = self._condition()
133
134
+ @self._loop.bind
135
+ def _():
136
+ pressed = self._condition()
137
138
+ if this._last_pressed != pressed:
139
+ command.schedule()
140
141
+ this._last_pressed = pressed
142
143
+ return self
144
145
def whileTrue(self, command: Command) -> Self:
146
"""
147
Starts the given command when the condition changes to `True` and cancels it when the condition
0 commit comments