Module ui.widget.container.inputcontainer
An InputContainer is a WidgetContainer that handles user input events including multi touches and key presses.
See InputContainer:registerTouchZones for examples of how to listen for multi touch input.
This example illustrates how to listen for a key press input event:
PanBy20 = { { "Shift", Input.group.Cursor }, seqtext = "Shift+Cursor", doc = "pan by 20px", event = "Pan", args = 20, is_inactive = true, }, PanNormal = { { Input.group.Cursor }, seqtext = "Cursor", doc = "pan by 10 px", event = "Pan", args = 10, }, Quit = { {"Home"} },
It is recommended to reference configurable sequences from another table and to store that table as a configuration setting.
Functions
InputContainer:registerTouchZones (zones) | Register touch zones into this InputContainer. |
InputContainer:updateTouchZonesOnScreenResize (new_screen_dimen) | Updates touch zones based on new screen dimensions. |
Functions
- InputContainer:registerTouchZones (zones)
-
Register touch zones into this InputContainer.
See gesturedetector for a list of supported gestures.
NOTE: You are responsible for calling self:updateTouchZonesOnScreenResize with the new screen dimensions whenever the screen is rotated or resized.
Parameters:
- zones table list of touch zones to register
Usage:
local InputContainer = require("ui/widget/container/inputcontainer") local test_widget = InputContainer:new{} test_widget:registerTouchZones({ { id = "foo_tap", ges = "tap", -- This binds the handler to the full screen screen_zone = { ratio_x = 0, ratio_y = 0, ratio_w = 1, ratio_h = 1, }, handler = function(ges) print('User tapped on screen!') return true end }, { id = "foo_swipe", ges = "swipe", -- This binds the handler to bottom half of the screen screen_zone = { ratio_x = 0, ratio_y = 0.5, ratio_w = 1, ratio_h = 0.5, }, handler = function(ges) print("User swiped at the bottom with direction:", ges.direction) return true end }, }) require("ui/uimanager"):show(test_widget)
- InputContainer:updateTouchZonesOnScreenResize (new_screen_dimen)
-
Updates touch zones based on new screen dimensions.
Parameters:
- new_screen_dimen ui.geometry.Geom new screen dimensions