Difference between revisions of "Mouse (Chili Framework)"

From Chilipedia
Jump to: navigation, search
(Created page with "With <code>Mouse</code>, you can get the current state of the mouse keys and the pointer position, and you can pop mouse events out of an <code>Event</code> queue contained in...")
 
Line 1: Line 1:
 
With <code>Mouse</code>, you can get the current state of the mouse keys and the pointer position, and you can pop mouse events out of an <code>Event</code> queue contained in <code>Mouse</code>. You can also check whether the mouse is in the window client region. Whopee. (''Note: lives in ''<code>MainWindow</code>'''s belly.'')
 
With <code>Mouse</code>, you can get the current state of the mouse keys and the pointer position, and you can pop mouse events out of an <code>Event</code> queue contained in <code>Mouse</code>. You can also check whether the mouse is in the window client region. Whopee. (''Note: lives in ''<code>MainWindow</code>'''s belly.'')
 +
 +
== Members ==
 +
=== KeyIsPressed ===
 +
<code>bool Keyboard::KeyIsPressed( unsigned char keycode ) const</code><br />
 +
Checks to see if a specific key is currently in the pressed state. The function parameter is the [[#Virtual Key Codes|virtual key code]] of the key that you want to check.
 +
 +
=== ReadKey ===
 +
<code>Event Keyboard::ReadKey()</code><br />
 +
Pull a fresh <code>[[#Event|Event]]</code> object out of the key press/release event queue. Erases an event from the queue and returns a copy if there is a key press event in the queue. Returns an invalid Event object if the queue is empty.
 +
 +
=== KeyIsEmpty ===
 +
<code>bool Keyboard::KeyIsEmpty() const</code><br />
 +
Returns <code>true</code> if the key event queue is empty.
 +
 +
=== ReadChar ===
 +
<code>char Keyboard::ReadChar()</code><br />
 +
Pull a fresh character off of the character queue. Returns a <code>'\0'</code> (null) character if the queue is empty. See also: [[#ReadKey vs. ReadChar|ReadKey vs. ReadChar]].
 +
 +
=== CharIsEmpty ===
 +
<code>bool Keyboard::CharIsEmpty() const</code><br />
 +
Returns <code>true</code> if the character queue is empty.
 +
 +
=== Buffer Flushing Bullshit ===
 +
<code>void Keyboard::FlushKey()</code><br />
 +
<code>void Keyboard::FlushChar()</code><br />
 +
<code>void Keyboard::Flush()</code><br />
 +
These functions empty the respective queues. Flush() empties both in one fell swoop. It's like taking a pee and a poo at the same time.
 +
 +
=== Autorepeat Bullshit ===
 +
<code>void Keyboard::EnableAutorepeat()</code><br />
 +
<code>void Keyboard::DisableAutorepeat()</code><br />
 +
<code>bool Keyboard::AutorepeatIsEnabled() const</code><br />
 +
If you hhhhhhhhhhhhhhhhhold a key down for a while, it will start machine gunning events and characters into your queues like a motherfucker. You can disable that if it pisses you off.
 +
 +
== Event ==
 +
<code>class Mouse::Event</code><br />
 +
 +
Mouse click, wheel, and move events are held in a queue in <code>Mouse</code> in the order they occurred. These events are modeled with their own class because they're precious fucking little snowflakes. They store the type of event and the state of the mouse after the event occurred. You pull them out of the buffer with <code>Mouse::Read()</code>.
 +
 +
=== Type ===
 +
<code>enum Mouse::Event::Type</code><br />
 +
 +
This represents the different types of events that can be recorded. The options are:
 +
* <code>LPress</code>
 +
* <code>LRelease</code>
 +
* <code>RPress</code>
 +
* <code>RRelease</code>
 +
* <code>WheelUp</code>
 +
* <code>WheelDown</code>
 +
* <code>Move</code>
 +
* <code>Invalid</code>
 +
 +
=== GetType ===
 +
<code>Type Mouse::Event::GetType() const</code><br />
 +
 +
Returns the type of the event. Example of use:
 +
 +
<syntaxhighlight lang="cpp" line="1" >
 +
const Mouse::Event e = wnd.mouse.Read();
 +
if( e.GetType() == Mouse::Event::LPress )
 +
{
 +
// respond to left mouse click
 +
}
 +
</syntaxhighlight>
 +
 +
=== IsRelease ===
 +
<code>bool Keyboard::Event::IsRelease() const</code><br />
 +
 +
Returns <code>true</code> if the event is a release event.
 +
 +
=== IsValid ===
 +
<code>bool Keyboard::Event::IsValid() const</code><br />
 +
 +
Returns <code>true</code> if the event is a valid event (reading from an empty buffer will return an invalid event object).
 +
 +
=== GetCode ===
 +
<code>char Keyboard::Event::GetCode() const</code><br />
 +
 +
Gets the virtual key code of the key associated with the <code>Event</code> object.
 +
 +
== See also ==
 +
* The [[Chili Framework]]

Revision as of 13:16, 14 July 2016

With Mouse, you can get the current state of the mouse keys and the pointer position, and you can pop mouse events out of an Event queue contained in Mouse. You can also check whether the mouse is in the window client region. Whopee. (Note: lives in MainWindow's belly.)

Members

KeyIsPressed

bool Keyboard::KeyIsPressed( unsigned char keycode ) const
Checks to see if a specific key is currently in the pressed state. The function parameter is the virtual key code of the key that you want to check.

ReadKey

Event Keyboard::ReadKey()
Pull a fresh Event object out of the key press/release event queue. Erases an event from the queue and returns a copy if there is a key press event in the queue. Returns an invalid Event object if the queue is empty.

KeyIsEmpty

bool Keyboard::KeyIsEmpty() const
Returns true if the key event queue is empty.

ReadChar

char Keyboard::ReadChar()
Pull a fresh character off of the character queue. Returns a '\0' (null) character if the queue is empty. See also: ReadKey vs. ReadChar.

CharIsEmpty

bool Keyboard::CharIsEmpty() const
Returns true if the character queue is empty.

Buffer Flushing Bullshit

void Keyboard::FlushKey()
void Keyboard::FlushChar()
void Keyboard::Flush()
These functions empty the respective queues. Flush() empties both in one fell swoop. It's like taking a pee and a poo at the same time.

Autorepeat Bullshit

void Keyboard::EnableAutorepeat()
void Keyboard::DisableAutorepeat()
bool Keyboard::AutorepeatIsEnabled() const
If you hhhhhhhhhhhhhhhhhold a key down for a while, it will start machine gunning events and characters into your queues like a motherfucker. You can disable that if it pisses you off.

Event

class Mouse::Event

Mouse click, wheel, and move events are held in a queue in Mouse in the order they occurred. These events are modeled with their own class because they're precious fucking little snowflakes. They store the type of event and the state of the mouse after the event occurred. You pull them out of the buffer with Mouse::Read().

Type

enum Mouse::Event::Type

This represents the different types of events that can be recorded. The options are:

  • LPress
  • LRelease
  • RPress
  • RRelease
  • WheelUp
  • WheelDown
  • Move
  • Invalid

GetType

Type Mouse::Event::GetType() const

Returns the type of the event. Example of use:

const Mouse::Event e = wnd.mouse.Read();
if( e.GetType() == Mouse::Event::LPress )
{
	// respond to left mouse click
}

IsRelease

bool Keyboard::Event::IsRelease() const

Returns true if the event is a release event.

IsValid

bool Keyboard::Event::IsValid() const

Returns true if the event is a valid event (reading from an empty buffer will return an invalid event object).

GetCode

char Keyboard::Event::GetCode() const

Gets the virtual key code of the key associated with the Event object.

See also