Gazebo Common

API Reference

4.8.1
gz/common/KeyEvent.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16 */
17 #ifndef GZ_COMMON_KEYEVENT_HH_
18 #define GZ_COMMON_KEYEVENT_HH_
19 
20 #include <memory>
21 #include <string>
22 
23 #include <gz/common/config.hh>
24 #include <gz/common/events/Export.hh>
26 
27 namespace ignition
28 {
29  namespace common
30  {
31  // Forward declare private data class
32  class KeyEventPrivate;
33 
36  class IGNITION_COMMON_EVENTS_VISIBLE KeyEvent
37  {
39  public: enum EventType {NO_EVENT, PRESS, RELEASE};
40 
42  public: KeyEvent();
43 
46  public: KeyEvent(const KeyEvent &_other);
47 
48  // \brief Move constructor.
50  public: KeyEvent(KeyEvent &&_other);
51 
53  public: ~KeyEvent();
54 
57  public: EventType Type() const;
58 
61  public: void SetType(const EventType _type);
62 
65  public: int Key() const;
66 
69  public: void SetKey(const int _key);
70 
74  public: std::string Text() const;
75 
78  public: void SetText(const std::string &_text);
79 
82  public: bool Control() const;
83 
86  public: void SetControl(const bool _control);
87 
90  public: bool Shift() const;
91 
94  public: void SetShift(const bool _shift);
95 
98  public: bool Alt() const;
99 
102  public: void SetAlt(const bool _alt);
103 
107  public: KeyEvent &operator=(const KeyEvent &_other);
108 
112  public: KeyEvent& operator=(KeyEvent&& other);
113 
116  private: std::unique_ptr<KeyEventPrivate> dataPtr;
118  };
119  }
120 }
121 #endif
Generic description of a keyboard event.
Definition: gz/common/KeyEvent.hh:37
void SetShift(const bool _shift)
Set whether the shift key was held during this key event.
bool Shift() const
Get whether the shift key was held during this key event.
EventType Type() const
Get the event type.
EventType
Key event types enumeration.
Definition: gz/common/KeyEvent.hh:39
int Key() const
Get the key number.
void SetControl(const bool _control)
Set whether the control key was held during this key event.
KeyEvent(const KeyEvent &_other)
Copy constructor.
void SetAlt(const bool _alt)
Set whether the alt key was held during this key event.
bool Control() const
Get whether the control key was held during this key event.
std::string Text() const
Get the formatted string of the key pressed (could be uppercase).
void SetText(const std::string &_text)
Set the formatted string of the key pressed.
void SetType(const EventType _type)
Set the event type.
KeyEvent(KeyEvent &&_other)
KeyEvent & operator=(KeyEvent &&other)
Move assignment operator.
void SetKey(const int _key)
Set the key.
KeyEvent & operator=(const KeyEvent &_other)
Assignment operator.
bool Alt() const
Get whether the alt key was held during this key event.
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: gz/common/SuppressWarning.hh:65
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: gz/common/SuppressWarning.hh:68
Forward declarations for the common classes.