Struct InputManipulator

pub struct InputManipulator(/* private fields */);
Expand description

The base class for the Kanzi input manipulators. Use the input manipulators to recognize gestures, such as click or pinch, or hardware key gestures from incoming events. Kanzi has specialized subclasses to handle touch gestures and hardware key gestures. Kanzi converts and handles mouse events as touch gestures.

To use an input manipulator on a node, add it to that node with the Node::addInputManipulator() method. You can add more than one input manipulator to a node, but you can use only one input manipulator to recognize a given gesture type. When you want to handle more than one gesture type on a node, link the input manipulators to each other in order of importance of the gestures that they recognize.

You can link input manipulators sequentially. For example, if you want a node to recognize the pan, double-click, and click gestures in this order, link the ClickManipulator to the MultiClickManipulator, and the MultiClickManipulator to the PanManipulator.

The linking of the manipulators is directional and hierarchical. The linked manipulator is called the dependant manipulator and the manipulator the dependant is linked to is called the fail manipulator. The dependant manipulator has lower priority than the fail manipulator. Lower priority manipulator succeeds only when the higher priority manipulators fail to recognize a gesture. You can link the two manipulators by calling requireToFail() on the dependant manipulator, passing the fail manipulator as argument.

To receive both click and multi-click messages on a node, you need to configure the click manipulator to wait for the failure of the multi-click manipulator:

If the dependant manipulator supports delay, when it recognizes a gesture and the fail manipulator has not finished recognizing a gesture, the dependant manipulator sets its own state to StateDelayed. When an input manipulator is in the StateDelayed state, it stops handling events and waits until the fail manipulator finishes recognizing its gesture.

If the fail manipulator fails, Kanzi calls the onFail() of the dependant manipulator. In that case the onFail() method generates the message that was delayed. If the fail manipulator succeeds, Kanzi cancels the dependant manipulator.

To add delay functionality to your own input manipulators, when that input manipulator recognizes a gesture and there is an input manipulator on which your input manipulator depends, your input manipulator must first enter the StateDelayed state. In this case, do not send any messages. When the fail manipulator fails, Kanzi calls the onFail() on your input manipulator. Use this method to send delayed messages. When the fail manipulator succeeds, Kanzi cancels your input manipulator.

You can cancel an input manipulator after it enters one of the following states: -StatePossible -StateBegin -StateChange -StateDelayed.

When you cancel an input manipulator, that input manipulator:

  • Stops receiving gesture recognition
  • Enters the StateCanceled state
  • Calls the onCancel() method
  • Enters the StateReady state

Kanzi cancels an input manipulator when:

  • You call cancel()
  • One of the other input manipulators that are attached to the same node enter one of these states:
  • StateBegin
  • StateChange
  • StateEnd.
  • An input manipulator is in one of these states and you call reset():
  • StateBegin
  • StateChange
  • StateEnd. Kanzi first cancels and then resets the input manipulator.

§Gesture recognition

Kanzi dispatches the incoming event data to manipulators attached to nodes in phases:

  • Kanzi tunnels the event data to nodes starting from the root node and ending at the hit test node or at the focus node. In this phase only the input manipulators that have the RoutingTunneling routing mode set receive the event data for recognition.
  • Kanzi continues to bubble the event data from the hit test or focus node node to the root node, updating the nodes with input manipulators that have the RoutingBubbling routing mode set.
  • Kanzi updates the input manipulators that are outside of the hierarchy of the hit test or active focus node.

The touch gesture recognition happens in the notifyTouchInside() or notifyTouchOutside() methods of an input manipulator. Every input manipulator attached to a hit test node receives all the touch points that occurred in the application. In each input manipulator you must set the correct state to inform Kanzi that the input manipulator recognized a gesture. You do this by calling the setState() method with the appropriate State value.

When an input manipulator recognizes a touch event as a starting action of a gesture:

  • The input manipulator enters the StatePossible state. Usually every input manipulator takes the first touch point as a possible starting point of the gesture it recognizes. In this phase, every input manipulator in the StatePossible state receives the touch event.
  • When the input manipulator recognizes the incoming touch event as a comprehensive gesture, depending on the type of the gesture, this input manipulator sets its state to either StateBegin, StateEnd, or StateFail state.
  • Input manipulators which recognize gestures where the touch point location is not changing, such as click or multi-click, and gestures where the touch location is updated, set the state to StateEnd.
  • If the gesture recognition fails, input manipulators set the StateFail state value. It is important that you mark the gesture recognition failure in the failing input manipulator. This enables Kanzi to continue dispatching the touch event to the dependant input manipulators. Kanzi calls onFail() method on the dependant input manipulator linked, continuing the gesture recognition in that input manipulator.

Key gesture recognition happens in the notifyKeyInput() method of an input manipulator. Every input manipulator attached to a node that is the focus node of the ascendant node of the focus node receives the key event. To recognize the key event as a key gesture, call the detectKeyGesture() method for each key gesture that your input manipulator handles. The method calls onPartialKeyPressGesture(), onKeyPressGesture(), and onKeyReleaseGesture() when Kanzi recognizes a key event as a partial key press gesture, a full key press gesture, or a key release gesture. A partial key press gesture usually happens with key gestures composed of a key value and key modifiers. Just like with touch gestures, in each input manipulator you must set the correct state to inform Kanzi that the input manipulator recognized a key gesture.

During and on gesture recognition, input manipulators can dispatch messages to the attached node, to inform the subscribed message handlers about the progress of the gesture.

See: ClickManipulator, DragAndDropManipulator, LongPressManipulator, MultiClickManipulator, PanManipulator, PinchManipulator

§InputManipulator examples

The key manipulator:

The multi-key manipulator:

Methods from Deref<Target = Object>§

pub fn as_ptr(&self) -> *mut ObjectWrapper

pub fn as_wrapper(&self) -> &ObjectWrapper

pub fn as_object(&self) -> &Object

Represents any type inheriting from Object as &Object. This is useful for comparisions when PartialEq traits failed to compare objects of different types.

let child = screen.get_child(0)?;
let parent = child.get_parent()?.into_error(ErrorKind::ObjectNotFound)?;
// assert_eq!(screen, parent); // <- Fails to compile!
assert_eq!(screen.as_object(), parent.as_object());

pub fn get_native(&self) -> Result<NonNull<c_void>, Error>

Gets a pointer to the backing C++ instance.

pub fn is_stale(&self) -> bool

Checks whether the weak reference has expired.

pub fn get_property<T>( &self, property_type: &PropertyType<T>, ) -> Result<<T as VariantConstraint>::RetArg, Error>

Returns the current value of a property disregarding modifiers.

Base value is affected by the following inputs where the highest entry in the list determines the base value:

  1. Local value set with setProperty or loaded from kzb
  2. Value set by a style affecting the property.
  3. Value defined by class metadata.

Modifiers are not applied, the highest-priority base value is returned.

If no inputs to the property value can be established the system returns the value default value from property type metadata.

§Arguments
  • property_type - The property type identifying the property to retrieve.
§Returns

The evaluated property value.

pub fn get_optional_property<T>( &self, property_type: &PropertyType<T>, ) -> Result<Option<<T as VariantConstraint>::RetArg>, Error>

Returns the current value of a property disregarding modifiers, but does not default to the value in property metadata if there are no inputs to the property value.

If there is no value sources, None is returned.

If no inputs to the property value can be established the system returns the value default value from property type metadata.

§Arguments
  • property_type - The property type identifying the property to retrieve.
§Returns

The evaluated property value.

pub fn set_property<T>( &self, property_type: &PropertyType<T>, value: <T as VariantConstraint>::DataArg<'_>, ) -> Result<(), Error>

Sets the local value of a property type.

pub fn has_value<T>( &self, property_type: &PropertyType<T>, ) -> Result<bool, Error>

Evaluates whether there are any inputs into the property value. Both value sources and modifiers are taken into account.

§Returns

Returns true if there are inputs into the property value, false otherwise.

pub fn remove_local_value<T>( &self, property_type: &PropertyType<T>, ) -> Result<(), Error>

Removes the local value associated with the property.

pub fn get_metaclass(&self) -> Result<Metaclass, Error>

Returns the metaclass of the dynamic type of the object.

pub fn get_domain(&self) -> Result<Domain, Error>

Returns the domain the object belongs to.

pub fn set_flag_keep_during_patching<T>( &self, property_type: &PropertyType<T>, ) -> Result<(), Error>

Sets the flag to indicate that the property was loaded from KZB.

pub fn debug_string(&self) -> Result<String, Error>

Builds a string representation of the object intended for debugging purposes.

Trait Implementations§

§

impl Clone for InputManipulator

§

fn clone(&self) -> InputManipulator

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for InputManipulator

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Deref for InputManipulator

§

type Target = Object

The resulting type after dereferencing.
§

fn deref(&self) -> &<InputManipulator as Deref>::Target

Dereferences the value.
§

impl Inheritable for InputManipulator

§

unsafe fn downcast_unchecked<T>(self) -> T
where T: Inherits<Self>,

Downcast the object to a more specific type. Read more
§

unsafe fn downcast_unchecked_ref<T>(&self) -> &T
where T: Inherits<Self>,

Downcast the object reference to a more specific type. Read more
§

impl Inherits<InputManipulator> for ClickManipulator

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

§

impl Inherits<InputManipulator> for DragAndDropManipulator

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

§

impl Inherits<InputManipulator> for FocusNavigationManipulator

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

§

impl Inherits<InputManipulator> for KeyManipulator

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

§

impl Inherits<InputManipulator> for LongPressManipulator

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

§

impl Inherits<InputManipulator> for MultiClickManipulator

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

§

impl Inherits<InputManipulator> for NavigationManipulator

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

§

impl Inherits<InputManipulator> for PanManipulator

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

§

impl Inherits<InputManipulator> for PinchManipulator

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

§

impl Inherits<InputManipulator> for TextInputManipulator

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

§

impl Inherits<Object> for InputManipulator

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

§

impl MetaclassConstraint for InputManipulator

§

fn get_static_metaclass() -> &'static Metaclass

Gets metaclass associated with a given type.
§

impl ObjectConstraint for InputManipulator

§

fn downcast<T>(self) -> Result<Option<T>, Error>
where T: MetaInherits<Self>,

Casts metaclass to a more specific type by value.
§

fn downcast_ref<T>(&self) -> Result<Option<&T>, Error>
where T: MetaInherits<Self>,

Casts metaclass to a more specific type by reference.
§

fn is_a<T>(&self) -> Result<bool, Error>
where T: MetaInherits<Self>,

Determines whether the class this metaclass describes derives from a class described by specified metaclass.
§

fn downgrade(self) -> Weak<Self>

§

fn downgrade_ref(&self) -> Weak<Self>

§

fn lock(self) -> ThreadObject<Self>

§

fn lock_ref(&self) -> ThreadObject<Self>

§

impl<T> PartialEq<T> for InputManipulator

§

fn eq(&self, rhs: &T) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T> PartialEq<Weak<T>> for InputManipulator

§

fn eq(&self, rhs: &Weak<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl Eq for InputManipulator

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AsAny for T
where T: 'static,

§

fn as_any(&self) -> &(dyn Any + 'static)

§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Inherits<T> for T

§

fn upcast(self) -> Base

§

fn upcast_ref(&self) -> &Base

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<Base, T> MetaInherits<Base> for T
where Base: ObjectConstraint, T: Inherits<Base> + ObjectConstraint,