Panda3D
mouseWatcherParameter.cxx
1 // Filename: mouseWatcherParameter.cxx
2 // Created by: drose (06Jul01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "mouseWatcherParameter.h"
16 
17 ////////////////////////////////////////////////////////////////////
18 // Function: MouseWatcherParameter::output
19 // Access: Published
20 // Description:
21 ////////////////////////////////////////////////////////////////////
22 void MouseWatcherParameter::
23 output(ostream &out) const {
24  bool output_anything = false;
25 
26  if (has_button()) {
27  out << _button;
28  output_anything = true;
29  }
30 
31  if (has_keycode()) {
32  if (output_anything) {
33  out << ", ";
34  }
35  out << "key" << _keycode;
36  output_anything = true;
37  }
38 
39  if (_mods.is_any_down()) {
40  if (output_anything) {
41  out << ", ";
42  }
43  out << _mods;
44  output_anything = true;
45  }
46 
47  if (has_mouse()) {
48  if (output_anything) {
49  out << ", ";
50  }
51  out << "(" << _mouse << ")";
52  output_anything = true;
53  }
54 
55  if (is_outside()) {
56  if (output_anything) {
57  out << ", ";
58  }
59  out << "outside";
60  output_anything = true;
61  }
62 
63  if (!output_anything) {
64  out << "no parameters";
65  }
66 }
bool has_mouse() const
Returns true if this parameter has an associated mouse position, false otherwise. ...
bool is_outside() const
Returns true if the mouse was outside the region at the time the event was generated, false otherwise.
bool is_any_down() const
Returns true if any of the tracked button are known to be down, or false if all of them are up...
bool has_button() const
Returns true if this parameter has an associated mouse or keyboard button, false otherwise.
bool has_keycode() const
Returns true if this parameter has an associated keycode, false otherwise.