Skip to content

Commit 896457c

Browse files
Examples
1 parent 57b83e4 commit 896457c

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

docs/frameworks/input-manager.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,30 @@ Disable or enable the top-menu drawer open action. When `disabled=True`, drawer-
153153
#### `is_drawer_open_disabled()`
154154
**Returns:** bool — True if drawer opening is currently disabled.
155155

156+
### Real-World Example
157+
158+
The [Emoji Sort](https://github.com/MicroPythonOS/MicroPythonOS/tree/main/internal_filesystem/apps/com.micropythonos.sorter) app (`com.micropythonos.sorter`) uses navigation gating for two purposes:
159+
160+
```python
161+
from mpos.ui.input_manager import InputManager
162+
163+
class Sorter(Activity):
164+
def onResume(self, screen):
165+
# Back button → exit confirmation dialog
166+
InputManager.set_back_screen_disabled(True, cb=self._show_exit_confirm)
167+
# Menu/drawer button → show solution guide
168+
InputManager.set_drawer_open_disabled(True, cb=lambda: self.on_help(None))
169+
170+
def onPause(self, screen):
171+
InputManager.set_back_screen_disabled(False)
172+
InputManager.set_drawer_open_disabled(False)
173+
super().onPause(screen)
174+
```
175+
176+
- **Back button** — shows "Exit the game?" confirmation dialog instead of navigating back.
177+
- **Menu/drawer-open button** — displays the level solution (step-by-step move instructions) instead of opening the system menu drawer.
178+
- Disabled state is cleared in `onPause()` so the gating only applies while the app is in the foreground.
179+
156180
## Related Frameworks
157181

158182
- **[DisplayMetrics](display-metrics.md)** - Display properties and pointer coordinates (uses InputManager)

0 commit comments

Comments
 (0)