You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/apps/app-lifecycle.md
+31Lines changed: 31 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -217,6 +217,37 @@ Activity Stack:
217
217
218
218
2.**Going back:** Framework first calls `onBackPressed()`. If it returns `True`, the activity stays foreground and must call `finish()` itself when ready. If it returns `False`, the current activity receives `onPause()` → `onStop()` → `onDestroy()`, and the previous activity receives `onResume()`
219
219
220
+
### Disabling Navigation Globally
221
+
222
+
Apps that need full control over the back and menu buttons can disable the system-level actions globally via `InputManager`:
223
+
224
+
```python
225
+
from mpos.ui.input_manager import InputManager
226
+
227
+
# Disable back-screen navigation (hardware back button, swipe-back gesture)
228
+
InputManager.set_back_screen_disabled(True)
229
+
230
+
# Disable top-menu drawer opening (hardware menu button, swipe-down gesture)
231
+
InputManager.set_drawer_open_disabled(True)
232
+
233
+
# Query current state
234
+
ifnot InputManager.is_back_screen_disabled():
235
+
InputManager.set_back_screen_disabled(True)
236
+
```
237
+
238
+
The same functions are also available as top-level `mpos` imports:
239
+
240
+
```python
241
+
import mpos
242
+
mpos.set_back_screen_disabled(True)
243
+
mpos.set_drawer_open_disabled(True)
244
+
```
245
+
246
+
-`close_drawer()` still works when drawer opening is disabled — you can close an already-open drawer.
247
+
-`finish_current_activity()` (called directly) is not gated, only `back_screen()`.
248
+
- All paths — hardware key handlers, gesture navigation, and programmatic calls — funnel through `back_screen()` and `open_drawer()`/`toggle_drawer()`, so a single call gates every trigger.
249
+
- When disabled, the back-screen and drawer-open actions invoke optional callbacks passed to `set_back_screen_disabled(True, cb=...)` and `set_drawer_open_disabled(True, cb=...)`. The callbacks receive no arguments. If no callback is set, the action is silently consumed.
0 commit comments