46 lines
8.5 KiB
HTML
46 lines
8.5 KiB
HTML
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - Special Topics - The Keyboard</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
|
||
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
|
||
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheKeyboard.html" title="The Keyboard" /><link rel="prev" href="TheKeyboard_CharacterConstants.html" title="Character Constants" /><link rel="next" href="TheKeyboard_KeyboardMessages.html" title="Keyboard Messages" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="TheKeyboard_CharacterConstants.html" title="Character Constants"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheKeyboard.html" title="The Keyboard"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="TheKeyboard_KeyboardMessages.html" title="Keyboard Messages"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - Special Topics - The Keyboard</div></div><div id="headerB">Prev: <a href="TheKeyboard_CharacterConstants.html">Character Constants</a> Up: <a href="TheKeyboard.html">The Keyboard</a> Next: <a href="TheKeyboard_KeyboardMessages.html">Keyboard Messages</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_JourneyOfAKeystroke"></a>Journey Of A Keystroke</h2></div></div></div><p>When the user presses a key, a series of events is launched to handle
|
||
that action. Let's follow the bits through the system after the user
|
||
presses a key on the keyboard.</p><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_JourneyOfAKeystroke_Step1"></a>Step 1: The Input Server Add-on</h3></div></div></div><p>When the user presses a key on the keyboard, the entity responsible for
|
||
recognizing this action is the Input Server add-on for the keyboard
|
||
device on which the key was pressed. The add-on uses the current keymap
|
||
(which it has obtained by calling
|
||
<a class="link" href="TheInputServer_Functions.html#get_key_map" title="get_key_map()"><code class="function">get_key_map()</code></a>)
|
||
to map the keycode to the character.</p><p>The add-on then constructs a
|
||
<code class="constant">B_KEY_DOWN</code> or <code class="constant">B_UNMAPPED_KEY_DOWN</code>
|
||
<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>,
|
||
containing both the raw keycode and the actual characters generated by
|
||
the key, and sends the message to the Application Server by calling the
|
||
<a class="link" href="BInputServerDevice.html#BInputServerDevice_EnqueueMessage" title="EnqueueMessage()"><code class="methodname">BInputServerDevice::EnqueueMessage()</code></a>
|
||
function.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_JourneyOfAKeystroke_Step2"></a>Step 2: The Application Server</h3></div></div></div><p>The Aplication Server receives the message from the Input Server add-on
|
||
and decides what to do with it. If the key pressed is something the
|
||
Application Server traps, like a workspace change keystroke, it gets
|
||
handled internally.</p><p>Otherwise, the Application server locates the active window and passes
|
||
the <a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>
|
||
along to its
|
||
<a class="link" href="BWindow.html#BWindow_DispatchMessage" title="DispatchMessage()"><code class="methodname">BWindow::DispatchMessage()</code></a>
|
||
function.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_JourneyOfAKeystroke_Step3"></a>Step 3: The Active Window</h3></div></div></div><p>The
|
||
<a class="link" href="BWindow.html#BWindow_DispatchMessage" title="DispatchMessage()"><code class="methodname">BWindow::DispatchMessage()</code></a>
|
||
function receives the
|
||
<a class="link" href="BMessage.html" title="BMessage"><code class="classname">BMessage</code></a>
|
||
from the
|
||
Application Server, and intercepts some keys (like menu shortcuts and the
|
||
<span class="keycap">Command</span>+<span class="keycap">W</span>
|
||
close window sequence). If it's not a key the
|
||
<a class="link" href="BWindow.html" title="BWindow"><code class="classname">BWindow</code></a>
|
||
class (or
|
||
derived class) wants to intercept, <code class="methodname">DispatchMessage()</code>
|
||
passes the message along to the currently focused view's
|
||
<a class="link" href="BView.html#BView_MessageReceived" title="MessageReceived()"><code class="methodname">BView::MessageReceived()</code></a>
|
||
function.</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="TheKeyboard_JourneyOfAKeystroke_Step4"></a>Step 4: The Focused View</h3></div></div></div><p>The message finally arrives at the view that's currently focused in the
|
||
active window. This view's
|
||
<a class="link" href="BView.html#BView_MessageReceived" title="MessageReceived()"><code class="methodname">MessageReceived()</code></a>
|
||
function processes the keypress in whatever way it wants to.</p><p>Likewise, when the key is released, a
|
||
<code class="constant">B_KEY_UP</code> or <code class="constant">B_UNMAPPED_KEY_UP</code> event
|
||
is sent through this same route.</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="TheKeyboard_CharacterConstants.html">Character Constants</a> Up: <a href="TheKeyboard.html">The Keyboard</a> Next: <a href="TheKeyboard_KeyboardMessages.html">Keyboard Messages</a> </div><div id="footerB"><div id="footerBL"><a href="TheKeyboard_CharacterConstants.html" title="Character Constants"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheKeyboard.html" title="The Keyboard"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="TheKeyboard_KeyboardMessages.html" title="Keyboard Messages"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
|
||
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
|
||
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>
|