Ignition Common

API Reference

3.14.0
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 IGNITION_COMMON_KEYEVENT_HH_
18 #define IGNITION_COMMON_KEYEVENT_HH_
19 
20 #include <memory>
21 #include <string>
22 
23 #include <ignition/common/events/Export.hh>
25 
26 namespace ignition
27 {
28  namespace common
29  {
30  // Forward declare private data class
31  class KeyEventPrivate;
32 
35  class IGNITION_COMMON_EVENTS_VISIBLE KeyEvent
36  {
38  public: enum EventType {NO_EVENT, PRESS, RELEASE};
39 
41  public: KeyEvent();
42 
45  public: KeyEvent(const KeyEvent &_other);
46 
47  // \brief Move constructor.
49  public: KeyEvent(KeyEvent &&_other);
50 
52  public: ~KeyEvent();
53 
56  public: EventType Type() const;
57 
60  public: void SetType(const EventType _type);
61 
64  public: int Key() const;
65 
68  public: void SetKey(const int _key);
69 
73  public: std::string Text() const;
74 
77  public: void SetText(const std::string &_text);
78 
81  public: bool Control() const;
82 
85  public: void SetControl(const bool _control);
86 
89  public: bool Shift() const;
90 
93  public: void SetShift(const bool _shift);
94 
97  public: bool Alt() const;
98 
101  public: void SetAlt(const bool _alt);
102 
106  public: KeyEvent &operator=(const KeyEvent &_other);
107 
111  public: KeyEvent& operator=(KeyEvent&& other);
112 
115  private: std::unique_ptr<KeyEventPrivate> dataPtr;
117  };
118  }
119 }
120 #endif
#define IGN_COMMON_WARN_IGNORE__DLL_INTERFACE_MISSING
Microsoft Visual Studio does not automatically export the interface information for member variables ...
Definition: SuppressWarning.hh:64
#define IGN_COMMON_WARN_RESUME__DLL_INTERFACE_MISSING
Definition: SuppressWarning.hh:67
Generic description of a keyboard event.
Definition: KeyEvent.hh:36
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: KeyEvent.hh:38
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.
Forward declarations for the common classes.