hooks for binding a "cursormove" event when the cursor moves

This commit is contained in:
John Loehrlein 2009-01-23 01:51:48 +00:00
parent 2c71002065
commit 5550aaa1d7
3 changed files with 70 additions and 0 deletions

View File

@ -155,6 +155,31 @@ get_cursor_position() const {
return _cursor_position;
}
////////////////////////////////////////////////////////////////////
// Function: PGEntry::get_cursor_X
// Access: Published
// Description: Returns the node position x of the cursor
////////////////////////////////////////////////////////////////////
INLINE float PGEntry::
get_cursor_X() const {
LightReMutexHolder holder(_lock);
return _cursor_def.get_x();
}
////////////////////////////////////////////////////////////////////
// Function: PGEntry::get_cursor_y
// Access: Published
// Description: Returns the node position y of the cursor
////////////////////////////////////////////////////////////////////
INLINE float PGEntry::
get_cursor_Y() const {
LightReMutexHolder holder(_lock);
return _cursor_def.get_y();
}
////////////////////////////////////////////////////////////////////
// Function: PGEntry::set_max_chars
// Access: Published
@ -488,6 +513,18 @@ get_erase_prefix() {
return "erase-";
}
////////////////////////////////////////////////////////////////////
// Function: PGEntry::get_cursormove_prefix
// Access: Published, Static
// Description: Returns the prefix that is used to define the cursor
// event for all PGEntries. The cursor event is the
// concatenation of this string followed by get_id().
////////////////////////////////////////////////////////////////////
INLINE string PGEntry::
get_cursormove_prefix() {
return "cursormove-";
}
////////////////////////////////////////////////////////////////////
// Function: PGEntry::get_accept_event
// Access: Published
@ -545,6 +582,17 @@ get_erase_event() const {
return get_erase_prefix() + get_id();
}
////////////////////////////////////////////////////////////////////
// Function: PGEntry::get_cursormove_event
// Access: Published
// Description: Returns the event name that will be thrown whenever
// the cursor moves
////////////////////////////////////////////////////////////////////
INLINE string PGEntry::
get_cursormove_event() const {
return get_cursormove_prefix() + get_id();
}
////////////////////////////////////////////////////////////////////
// Function: PGEntry::set_wtext
// Access: Published

View File

@ -516,6 +516,19 @@ erase(const MouseWatcherParameter &param) {
throw_event(event, EventParameter(ep));
}
////////////////////////////////////////////////////////////////////
// Function: PGEntry::cursormove
// Access: Public, Virtual
// Description: This is a callback hook function, called whenever the
// cursor moves.
////////////////////////////////////////////////////////////////////
void PGEntry::
cursormove() {
LightReMutexHolder holder(_lock);
string event = get_cursormove_event();
throw_event(event, EventParameter(_cursor_def.get_x()), EventParameter(_cursor_def.get_y()));
}
////////////////////////////////////////////////////////////////////
// Function: PGEntry::setup
// Access: Published
@ -844,6 +857,8 @@ update_cursor() {
_cursor_def.set_pos(xpos, 0.0f, ypos);
_cursor_stale = false;
cursormove();
}
// Should the cursor be visible?

View File

@ -61,6 +61,7 @@ public:
virtual void overflow(const MouseWatcherParameter &param);
virtual void type(const MouseWatcherParameter &param);
virtual void erase(const MouseWatcherParameter &param);
virtual void cursormove();
PUBLISHED:
enum State {
@ -83,6 +84,9 @@ PUBLISHED:
INLINE void set_cursor_position(int position);
INLINE int get_cursor_position() const;
INLINE float get_cursor_X() const;
INLINE float get_cursor_Y() const;
INLINE void set_max_chars(int max_chars);
INLINE int get_max_chars() const;
@ -120,12 +124,15 @@ PUBLISHED:
INLINE static string get_overflow_prefix();
INLINE static string get_type_prefix();
INLINE static string get_erase_prefix();
INLINE static string get_cursormove_prefix();
INLINE string get_accept_event(const ButtonHandle &button) const;
INLINE string get_accept_failed_event(const ButtonHandle &button) const;
INLINE string get_overflow_event() const;
INLINE string get_type_event() const;
INLINE string get_erase_event() const;
INLINE string get_cursormove_event() const;
INLINE bool set_wtext(const wstring &wtext);
INLINE wstring get_plain_wtext() const;