Kanzi Engine API
kanzi::KeyInputConceptImpl< TDerivedClass > Class Template Reference

This template class enables you to implement key gestures recognition for a single key and its attached modifiers. More...

#include <kanzi/core.ui/input/key_input_concept.hpp>

Inheritance diagram for kanzi::KeyInputConceptImpl< TDerivedClass >:
[legend]

Public Member Functions

bool detectKeyGesture (const KeyEvent &event)
 Detects key gestures from the event that you pass as an argument. More...
 
- Public Member Functions inherited from kanzi::KeyInputConcept
CapsLockState getCapsLock () const
 Returns the required Caps Lock state for the key gesture. More...
 
pair< LogicalKey, KeyModifiergetKey () const
 Returns the composing elements of a key gesture. More...
 
bool isCapsLockGrabbed () const
 Returns whether the Caps Lock mode was on when the gesture detector set this key gesture as grabbed. More...
 
bool isEnabled () const
 Returns the enabled state of a key gesture. More...
 
bool isGrabbed () const
 Returns the grabbed state of a key gesture. More...
 
 KeyInputConcept ()=default
 Constructor. More...
 
 KeyInputConcept (LogicalKey key, KeyModifier modifier, CapsLockState caps)
 Constructor. More...
 
 KeyInputConcept (LogicalKey key, KeyModifier modifier)
 Constructor. More...
 
 KeyInputConcept (LogicalKey key)
 Constructor. More...
 
void setCapsLock (CapsLockState capsLock)
 Sets the required Caps Lock state for the key gesture. More...
 
void setCapsLockGrabbed (bool capsLock)
 Sets whether the Caps Lock mode of the keyboard is on at the time Kanzi grabs the key gesture. More...
 
void setEnabled (bool enabled)
 Sets the enabled state of the key gesture. More...
 
void setGrabbed (bool grabbed)
 Sets the grabbed state of the key gesture. More...
 
void setKey (LogicalKey key, KeyModifier modifiers)
 Sets the key gesture composing elements to handle. More...
 
void setKey (LogicalKey key)
 Sets the key gesture composed of a logical key value with no key modifier. More...
 
virtual ~KeyInputConcept ()=default
 Destructor. More...
 

Protected Member Functions

void grabGesture ()
 Grabs the gesture. More...
 
 KeyInputConceptImpl ()=default
 Constructor. More...
 
void ungrabGesture ()
 Ungrabs the gesture. More...
 
- Protected Member Functions inherited from kanzi::KeyInputGestureDetector< TDerivedClass, KeyInputConcept >
bool detectKeyGesture (const KeyEvent &event, KeyInputConcept &gesture)
 Detects key gestures from the event that you pass as an argument. More...
 
void grabGesture (KeyInputConcept &gesture)
 Grabs a gesture. More...
 
 KeyInputGestureDetector ()=default
 Constructor. More...
 
void ungrabGesture (KeyInputConcept &gesture)
 Ungrabs a gesture. More...
 

Additional Inherited Members

- Protected Attributes inherited from kanzi::KeyInputConcept
bool m_capsLock
 Holds the Caps Lock state at the time Kanzi grabs the key gesture. More...
 
CapsLockState m_capsLockState
 Holds the required Caps Lock state for the key gesture. More...
 
LogicalKey m_code
 The logical key value. More...
 
bool m_isEnabled
 Holds the enabled state of a gesture. More...
 
bool m_isGrabbed
 Holds the grabbed state of a gesture. More...
 
KeyModifier m_modifiers
 The key modifiers. More...
 

Detailed Description

template<typename TDerivedClass>
class kanzi::KeyInputConceptImpl< TDerivedClass >

This template class enables you to implement key gestures recognition for a single key and its attached modifiers.

See also
KeyInputConcept, KeyRepeatConcept, KeyRepeatConceptImpl, KeyManipulator
Since
Kanzi 3.8.0

Examples

To create a simple key manipulator:

class SampleKeyManipulator;
using SampleKeyManipulatorSharedPtr = shared_ptr<SampleKeyManipulator>;
// This is a sample key manipulator which recognizes any key gesture, except the key-hold and key-repeat gestures.
class SampleKeyManipulator : public InputManipulator, public KeyInputConceptImpl<SampleKeyManipulator>
{
public:
static SampleKeyManipulatorSharedPtr create(Domain* domain)
{
return make_polymorphic_shared_ptr<InputManipulator>(new SampleKeyManipulator(domain));
}
protected:
explicit SampleKeyManipulator(Domain* domain) :
InputManipulator(domain, ManipulatorType::KeyInputHandler)
{
}
bool notifyKeyInput(const KeyEvent& event) override
{
// Invoke the gesture detection.
return detectKeyGesture(event);
}
void onCancel() override
{
// Add here the code that you want to use for key cancellation.
// Ungrab the key gestures recognition.
}
void onReset() override
{
// Ungrab the key gestures recognition.
}
void notifyPartialKeyPressGesture(KeyInputConcept&)
{
// The key gesture is partially recognized. Typically set the manipulator state to StatePossible.
// You can add your code after you set the manipulator state.
setState(StatePossible);
}
void notifyKeyPressGesture(KeyInputConcept&)
{
// The key gesture is detected as a whole. Set the manipulator state to StateBegin.
// You can add your code after you set the manipulator state.
setState(StateBegin);
}
void notifyKeyReleaseGesture(KeyInputConcept&)
{
// The key gesture release is detected. Set the manipulator state to StateEnd.
// You can add your code after you set the manipulator state.
setState(StateEnd);
}
// Make the concept implementation template specialization as a friend so that you do not have to
// declare the manipulator gesture notification methods in the public scope of your manipulator.
friend class KeyInputGestureDetector<SampleKeyManipulator, KeyInputConcept>;
friend class KeyInputConceptImpl<SampleKeyManipulator>;
};

Constructor & Destructor Documentation

template<typename TDerivedClass>
kanzi::KeyInputConceptImpl< TDerivedClass >::KeyInputConceptImpl ( )
explicitprotecteddefault

Constructor.

Member Function Documentation

template<typename TDerivedClass >
bool kanzi::KeyInputConceptImpl< TDerivedClass >::detectKeyGesture ( const KeyEvent event)

Detects key gestures from the event that you pass as an argument.

Call this method to detect a key gesture from a key event.

Parameters
eventThe event to detect the key gesture.
Returns
If the key event matches the key gesture, returns true. If the key does not match the gesture, or only partially matches it, returns false.
template<typename TDerivedClass >
void kanzi::KeyInputConceptImpl< TDerivedClass >::grabGesture ( )
protected

Grabs the gesture.

template<typename TDerivedClass >
void kanzi::KeyInputConceptImpl< TDerivedClass >::ungrabGesture ( )
protected

Ungrabs the gesture.


The documentation for this class was generated from the following files: