Input.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=11"/>
  6. <meta name="generator" content="Doxygen 1.9.8"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  8. <title>Nuklear: Input</title>
  9. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  13. <script type="text/javascript" src="resize.js"></script>
  14. <script type="text/javascript" src="navtreedata.js"></script>
  15. <script type="text/javascript" src="navtree.js"></script>
  16. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  17. <script type="text/javascript" src="search/searchdata.js"></script>
  18. <script type="text/javascript" src="search/search.js"></script>
  19. <script type="text/javascript">
  20. /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
  21. $(document).ready(function() { init_search(); });
  22. /* @license-end */
  23. </script>
  24. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  25. <link href="doxygen-awesome.css" rel="stylesheet" type="text/css"/>
  26. </head>
  27. <body>
  28. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  29. <div id="titlearea">
  30. <table cellspacing="0" cellpadding="0">
  31. <tbody>
  32. <tr id="projectrow">
  33. <td id="projectalign">
  34. <div id="projectname">Nuklear
  35. </div>
  36. <div id="projectbrief">This is a minimal-state, immediate-mode graphical user interface toolkit written in ANSI C and licensed under public domain. It was designed as a simple embeddable user interface for application and does not have any dependencies, a default render backend or OS window/input handling but instead provides a highly modular, library-based approach, with simple input state for input and draw commands describing primitive shapes as output. So instead of providing a layered library that tries to abstract over a number of platform and render backends, it focuses only on the actual UI.</div>
  37. </td>
  38. <td> <div id="MSearchBox" class="MSearchBoxInactive">
  39. <span class="left">
  40. <span id="MSearchSelect" onmouseover="return searchBox.OnSearchSelectShow()" onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
  41. <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
  42. onfocus="searchBox.OnSearchFieldFocus(true)"
  43. onblur="searchBox.OnSearchFieldFocus(false)"
  44. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  45. </span><span class="right">
  46. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
  47. </span>
  48. </div>
  49. </td>
  50. </tr>
  51. </tbody>
  52. </table>
  53. </div>
  54. <!-- end header part -->
  55. <!-- Generated by Doxygen 1.9.8 -->
  56. <script type="text/javascript">
  57. /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
  58. var searchBox = new SearchBox("searchBox", "search/",'.html');
  59. /* @license-end */
  60. </script>
  61. </div><!-- top -->
  62. <div id="side-nav" class="ui-resizable side-nav-resizable">
  63. <div id="nav-tree">
  64. <div id="nav-tree-contents">
  65. <div id="nav-sync" class="sync"></div>
  66. </div>
  67. </div>
  68. <div id="splitbar" style="-moz-user-select:none;"
  69. class="ui-resizable-handle">
  70. </div>
  71. </div>
  72. <script type="text/javascript">
  73. /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
  74. $(document).ready(function(){initNavTree('Input.html',''); initResizable(); });
  75. /* @license-end */
  76. </script>
  77. <div id="doc-content">
  78. <!-- window showing the filter options -->
  79. <div id="MSearchSelectWindow"
  80. onmouseover="return searchBox.OnSearchSelectShow()"
  81. onmouseout="return searchBox.OnSearchSelectHide()"
  82. onkeydown="return searchBox.OnSearchSelectKey(event)">
  83. </div>
  84. <!-- iframe showing the search results (closed by default) -->
  85. <div id="MSearchResultsWindow">
  86. <div id="MSearchResults">
  87. <div class="SRPage">
  88. <div id="SRIndex">
  89. <div id="SRResults"></div>
  90. <div class="SRStatus" id="Loading">Loading...</div>
  91. <div class="SRStatus" id="Searching">Searching...</div>
  92. <div class="SRStatus" id="NoMatches">No Matches</div>
  93. </div>
  94. </div>
  95. </div>
  96. </div>
  97. <div><div class="header">
  98. <div class="headertitle"><div class="title">Input</div></div>
  99. </div><!--header-->
  100. <div class="contents">
  101. <div class="textblock"><p>The input API is responsible for holding the current input state composed of mouse, key and text input states.</p>
  102. <p>It is worth noting that no direct OS or window handling is done in nuklear. Instead all input state has to be provided by platform specific code. This on one hand expects more work from the user and complicates usage but on the other hand provides simple abstraction over a big number of platforms, libraries and other already provided functionality.</p>
  103. <div class="fragment"><div class="line"><a class="code hl_function" href="nuklear_8h.html#a1dd51949401094f71d10429d45779d53">nk_input_begin</a>(&amp;ctx);</div>
  104. <div class="line"><span class="keywordflow">while</span> (GetEvent(&amp;evt)) {</div>
  105. <div class="line"> <span class="keywordflow">if</span> (evt.type == MOUSE_MOVE)</div>
  106. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#acdbdc5795b24d36875281cf3cac671fe">nk_input_motion</a>(&amp;ctx, evt.motion.x, evt.motion.y);</div>
  107. <div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (evt.type == [...]) {</div>
  108. <div class="line"> <span class="comment">// [...]</span></div>
  109. <div class="line"> }</div>
  110. <div class="line">} <a class="code hl_function" href="nuklear_8h.html#a15c0d237b6bb2f5195a09e259fd7b375">nk_input_end</a>(&amp;ctx);</div>
  111. <div class="ttc" id="anuklear_8h_html_a15c0d237b6bb2f5195a09e259fd7b375"><div class="ttname"><a href="nuklear_8h.html#a15c0d237b6bb2f5195a09e259fd7b375">nk_input_end</a></div><div class="ttdeci">NK_API void nk_input_end(struct nk_context *)</div><div class="ttdoc">End the input mirroring process by resetting mouse grabbing state to ensure the mouse cursor is not g...</div><div class="ttdef"><b>Definition</b> <a href="nuklear__input_8c_source.html#l00030">nuklear_input.c:30</a></div></div>
  112. <div class="ttc" id="anuklear_8h_html_a1dd51949401094f71d10429d45779d53"><div class="ttname"><a href="nuklear_8h.html#a1dd51949401094f71d10429d45779d53">nk_input_begin</a></div><div class="ttdeci">NK_API void nk_input_begin(struct nk_context *)</div><div class="ttdoc">Begins the input mirroring process by resetting text, scroll mouse, previous mouse position and movem...</div><div class="ttdef"><b>Definition</b> <a href="nuklear__input_8c_source.html#l00010">nuklear_input.c:10</a></div></div>
  113. <div class="ttc" id="anuklear_8h_html_acdbdc5795b24d36875281cf3cac671fe"><div class="ttname"><a href="nuklear_8h.html#acdbdc5795b24d36875281cf3cac671fe">nk_input_motion</a></div><div class="ttdeci">NK_API void nk_input_motion(struct nk_context *, int x, int y)</div><div class="ttdoc">Mirrors current mouse position to nuklear.</div><div class="ttdef"><b>Definition</b> <a href="nuklear__input_8c_source.html#l00045">nuklear_input.c:45</a></div></div>
  114. </div><!-- fragment --><h1><a class="anchor" id="autotoc_md15"></a>
  115. Usage</h1>
  116. <p>Input state needs to be provided to nuklear by first calling <code>nk_input_begin</code> which resets internal state like delta mouse position and button transitions. After <code>nk_input_begin</code> all current input state needs to be provided. This includes mouse motion, button and key pressed and released, text input and scrolling. Both event- or state-based input handling are supported by this API and should work without problems. Finally after all input state has been mirrored <code>nk_input_end</code> needs to be called to finish input process.</p>
  117. <div class="fragment"><div class="line"><span class="keyword">struct </span><a class="code hl_struct" href="structnk__context.html">nk_context</a> ctx;</div>
  118. <div class="line">nk_init_xxx(&amp;ctx, ...);</div>
  119. <div class="line"><span class="keywordflow">while</span> (1) {</div>
  120. <div class="line"> Event evt;</div>
  121. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#a1dd51949401094f71d10429d45779d53">nk_input_begin</a>(&amp;ctx);</div>
  122. <div class="line"> <span class="keywordflow">while</span> (GetEvent(&amp;evt)) {</div>
  123. <div class="line"> <span class="keywordflow">if</span> (evt.type == MOUSE_MOVE)</div>
  124. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#acdbdc5795b24d36875281cf3cac671fe">nk_input_motion</a>(&amp;ctx, evt.motion.x, evt.motion.y);</div>
  125. <div class="line"> <span class="keywordflow">else</span> <span class="keywordflow">if</span> (evt.type == [...]) {</div>
  126. <div class="line"> <span class="comment">// [...]</span></div>
  127. <div class="line"> }</div>
  128. <div class="line"> }</div>
  129. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#a15c0d237b6bb2f5195a09e259fd7b375">nk_input_end</a>(&amp;ctx);</div>
  130. <div class="line"> <span class="comment">// [...]</span></div>
  131. <div class="line"> <a class="code hl_function" href="nuklear_8h.html#ade3301f0a92370be1b4beac7eceac279">nk_clear</a>(&amp;ctx);</div>
  132. <div class="line">} <a class="code hl_function" href="nuklear_8h.html#a06772e194320fa99524681fd32df85e9">nk_free</a>(&amp;ctx);</div>
  133. <div class="ttc" id="anuklear_8h_html_a06772e194320fa99524681fd32df85e9"><div class="ttname"><a href="nuklear_8h.html#a06772e194320fa99524681fd32df85e9">nk_free</a></div><div class="ttdeci">NK_API void nk_free(struct nk_context *)</div><div class="ttdoc">Frees all memory allocated by nuklear; Not needed if context was initialized with nk_init_fixed.</div><div class="ttdef"><b>Definition</b> <a href="nuklear__context_8c_source.html#l00088">nuklear_context.c:88</a></div></div>
  134. <div class="ttc" id="anuklear_8h_html_ade3301f0a92370be1b4beac7eceac279"><div class="ttname"><a href="nuklear_8h.html#ade3301f0a92370be1b4beac7eceac279">nk_clear</a></div><div class="ttdeci">NK_API void nk_clear(struct nk_context *)</div><div class="ttdoc">Resets the context state at the end of the frame.</div><div class="ttdef"><b>Definition</b> <a href="nuklear__context_8c_source.html#l00110">nuklear_context.c:110</a></div></div>
  135. <div class="ttc" id="astructnk__context_html"><div class="ttname"><a href="structnk__context.html">nk_context</a></div><div class="ttdef"><b>Definition</b> <a href="nuklear_8h_source.html#l05705">nuklear.h:5705</a></div></div>
  136. </div><!-- fragment --><h1><a class="anchor" id="autotoc_md16"></a>
  137. Reference</h1>
  138. <table class="markdownTable">
  139. <tr class="markdownTableHead">
  140. <th class="markdownTableHeadNone">Function </th><th class="markdownTableHeadNone">Description </th></tr>
  141. <tr class="markdownTableRowOdd">
  142. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#a1dd51949401094f71d10429d45779d53">nk_input_begin</a> </td><td class="markdownTableBodyNone">Begins the input mirroring process. Needs to be called before all other <code>nk_input_xxx</code> calls </td></tr>
  143. <tr class="markdownTableRowEven">
  144. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#acdbdc5795b24d36875281cf3cac671fe">nk_input_motion</a> </td><td class="markdownTableBodyNone">Mirrors mouse cursor position </td></tr>
  145. <tr class="markdownTableRowOdd">
  146. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#a5d73e825488390b84483762d1265eb43">nk_input_key</a> </td><td class="markdownTableBodyNone">Mirrors key state with either pressed or released </td></tr>
  147. <tr class="markdownTableRowEven">
  148. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#ab25cec61c5c9d134f1516f1f30f6eec6">nk_input_button</a> </td><td class="markdownTableBodyNone">Mirrors mouse button state with either pressed or released </td></tr>
  149. <tr class="markdownTableRowOdd">
  150. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#abfc42a2f22d2f4404305ec8a82429290">nk_input_scroll</a> </td><td class="markdownTableBodyNone">Mirrors mouse scroll values </td></tr>
  151. <tr class="markdownTableRowEven">
  152. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#ab9d1ed53c659bd03c8c1c9fc2d9b212f">nk_input_char</a> </td><td class="markdownTableBodyNone">Adds a single ASCII text character into an internal text buffer </td></tr>
  153. <tr class="markdownTableRowOdd">
  154. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#af1d13fdae700f9c0dcd6b683701b71ba">nk_input_glyph</a> </td><td class="markdownTableBodyNone">Adds a single multi-byte UTF-8 character into an internal text buffer </td></tr>
  155. <tr class="markdownTableRowEven">
  156. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#a576737a9d5fd115e5007f99c5c8aa4cd">nk_input_unicode</a> </td><td class="markdownTableBodyNone">Adds a single unicode rune into an internal text buffer </td></tr>
  157. <tr class="markdownTableRowOdd">
  158. <td class="markdownTableBodyNone"><a class="el" href="nuklear_8h.html#a15c0d237b6bb2f5195a09e259fd7b375">nk_input_end</a> </td><td class="markdownTableBodyNone">Ends the input mirroring process by calculating state changes. Don't call any <code>nk_input_xxx</code> function referenced above after this call </td></tr>
  159. </table>
  160. </div></div><!-- contents -->
  161. </div><!-- PageDoc -->
  162. </div><!-- doc-content -->
  163. <!-- start footer part -->
  164. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  165. <ul>
  166. <li class="footer">Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.8 </li>
  167. </ul>
  168. </div>
  169. </body>
  170. </html>