Skip to content

Commit

Permalink
Add enable_keyboard for C++ and separate callback description (#138)
Browse files Browse the repository at this point in the history
  • Loading branch information
CMDR-Vulkarius committed Oct 10, 2023
1 parent 401fcb3 commit 0f19a4f
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions programming/hardware-support/keyboard-support.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ Panda3D has keyboard support built-in. Keyboard presses send
when it is first pressed down, when it is released, and one repeatedly while
it is pressed.

.. only:: cpp

Begin first by enabling keyboard events from the WindowFramework object:

.. code-block:: cpp
window->enable_keyboard();
The events can be accepted with the following code:

.. only:: python
Expand All @@ -22,16 +30,20 @@ The events can be accepted with the following code:
self.acceptOnce(<event name>, <function>)
self.acceptOnce(<event name>, <function>, <parameters list>)
<event name> is a string that labels the event. <function> is a python function
to be called when the event is sent. <parameters list> is a python list of
parameters to use to call <function>.

.. only:: cpp

.. code-block:: cpp
framework->define_key(<event name>, <description>, <function>, nullptr);
framework->define_key(<event name>, <description>, <function>, <data>);
<event name> is a string that labels the event. <function> is a python function
to be called when the event is sent. <parameters list> is a python list of
parameters to use to call <function>.
<event name> is a string that labels the event. <function> is an EventCallbackFunction
to be called when the event is sent. <data> is an arbitrary pointer to be passed when
the framework calls <function>.

.. only:: python

Expand Down

0 comments on commit 0f19a4f

Please sign in to comment.