Commit 47fef68f authored by Jan Möbius's avatar Jan Möbius

KeyInterface Documentation

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11128 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e1891d50
......@@ -46,16 +46,20 @@
#include <QtGui>
/** \brief Interface class for plugins which have to react on keyboard events
*
* Using this interface you can react on key events. You first have to register
* a key (or key combination). For each registered key you will receive a keyEvent when
* the key was pressed and a keyReleaseEvent when the key was released.
*
* See our tutorial \ref ex3 for an example of how to use mouse and keyboard events
* within a plugin.
*
*/
/** \file KeyInterface.hh
*
* Interface for receiving keyboard events inside your plugin.\ref keyInterfacePage
*/
/** \brief Keyboard Event Interface
*
* \ref keyInterfacePage "Detailed description"
* \n
*
* Using this interface you can react on key events.
*/
class KeyInterface {
signals:
/** \brief Register a key-combination for your plugin
......@@ -68,7 +72,7 @@ class KeyInterface {
* @param _description a short description about the functionality
* @param _multiUse can the key additionally be registered by another plugin
*/
virtual void registerKey(int /*_key*/, Qt::KeyboardModifiers /*_modifiers*/, QString /*_description*/, bool /*_multiUse*/ = false) {};
virtual void registerKey(int _key, Qt::KeyboardModifiers _modifiers, QString _description, bool _multiUse = false) {};
public slots :
......@@ -77,14 +81,14 @@ class KeyInterface {
* This slot is called if a key event occured in the Viewer
* @param _event Keyevent
*/
virtual void slotKeyEvent( QKeyEvent* /*_event*/ ) {};
virtual void slotKeyEvent( QKeyEvent* _event ) {};
/** \brief Key Release Event from Main App
*
* This slot is called if a key release event occured in the Viewer
* @param _event Keyevent
*/
virtual void slotKeyReleaseEvent( QKeyEvent* /*_event*/ ) {};
virtual void slotKeyReleaseEvent( QKeyEvent* _event ) {};
public :
......@@ -93,6 +97,78 @@ class KeyInterface {
};
/** \page keyInterfacePage Key Interface
\image html keyInterface.png
\n
Using this interface you can react on key events. You first have to register
a key (or key combination) with KeyInterface::registerKey().
Note that the log widget will contain a warning if you register
a key twice or it is occupied by another plugin.
For each registered key your KeyInterface::slotKeyEvent() will be triggered when
the key was pressed and the slot KeyInterface::slotKeyReleaseEvent() when the key
was released. Both slots get the QKeyEvent and will contain all the modifiers
that were active when the event occurred.
In OpenFlippers options tab you can view all registered keys and reassign them.
The events will be mapped, such that the plugins still receive the right combination.
Therefore the mapping will be completely invisible to them.
See our tutorial \ref ex3 for an example of how to use mouse and keyboard events
within a plugin.
To use the KeyInterface:
<ul>
<li> include KeyInterface.hh in your plugins header file
<li> derive your plugin from the class KeyInterface
<li> add Q_INTERFACES(KeyInterface) to your plugin class
<li> Implement the required functions.
</ul>
\code
// In your plugin initialization register the keys you want to get.
void ExamplePlugin::initializePlugin() {
// Register keys
emit registerKey(Qt::Key_W, Qt::NoModifier, "Rotate object down");
emit registerKey(Qt::Key_A, Qt::NoModifier, "Rotate object left");
emit registerKey(Qt::Key_D, Qt::NoModifier, "Rotate object right");
emit registerKey(Qt::Key_S, Qt::NoModifier, "Rotate object up");
}
// Called when one of the registered Keys is pressed.
void MouseAndKeyPlugin::slotKeyEvent( QKeyEvent* _event ) {
// Check if it's really the right key
if ( _event->modifiers() == Qt::NoModifier ) {
// Switch pressed keys
switch (_event->key()) {
case Qt::Key_W:
// Move forward
break;
case Qt::Key_A:
// Move left
break;
case Qt::Key_D:
// Move right
break;
case Qt::Key_S:
// Move backward
break;
default:
break;
}
}
}
\endcode
*/
Q_DECLARE_INTERFACE(KeyInterface,"OpenFlipper.KeyInterface/1.1")
#endif // KEYINTERFACE_HH
......@@ -57,7 +57,6 @@ The following groups of Interfaces are available:
BackupInterface
FileInterface
IniInterface
KeyInterface
LoadSaveInterface
PickingInterface
ProcessInterface
......@@ -70,10 +69,6 @@ ViewModeInterface
This page gives an overview over the available interfaces which control other parts of OpenFlipper.
\subsection KeyPlugin Keyboard Interface
\image html keyInterface.png
You have to provide this interface if you want to get key events in your plugin ( KeyInterface ).\n
\subsection LoadSavePlugin Load / Save Interface
\image html loadSaveInterface.png
......@@ -96,7 +91,6 @@ Handle mouse picking in your plugin ( PickingInterface )
Provides functions to read and write custom filetypes ( FileInterface )
\subsection ViewModePlugin View Mode Interface
\image html ViewModeInterface.png
Specify own view modes ( ViewModeInterface )
......@@ -144,7 +138,6 @@ This Interface is used by plugins which will provide their own options by
integrating an options widget into OpenFlipper's options window ( \ref optionsInterfacePage ).
\n
\subpage statusbarInterfacePage
\image html StatusbarInterface.png
This interface is used to display messages in the status bar or adding widgets to it ( \ref statusbarInterfacePage ).
......@@ -183,6 +176,10 @@ This page shows interfaces which could be used to get data from input devices.
This interface is used to deliver mouse events to a plugin ( \ref mouseInterfacePage ).\n
\n
\subpage keyInterfacePage
\image html keyInterface.png
You have to implement this interface if you want to get key events in your plugin ( \ref keyInterfacePage ).\n
*/
/** \page pluginInterfacesOtherInterfaces Other Interfaces
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment