-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
27777c3
commit a92165a
Showing
1 changed file
with
123 additions
and
0 deletions.
There are no files selected for viewing
123 changes: 123 additions & 0 deletions
123
Manual/contents/GameMaker_Language/GML_Reference/Debugging/dbg_button.htm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<!DOCTYPE html> | ||
<html xmlns="http://www.w3.org/1999/xhtml"> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> | ||
<title>dbg_button</title> | ||
<meta name="generator" content="Adobe RoboHelp 2022" /> | ||
<link rel="stylesheet" type="text/css" href="../../../assets/css/default.css" /> | ||
<script src="../../../assets/scripts/main_script.js" type="module"></script> | ||
<meta name="rh-authors" content="" /> | ||
<meta name="topic-comment" content="" /> | ||
<meta name="rh-index-keywords" content="" /> | ||
<meta name="search-keywords" content="" /> | ||
<meta name="template" content="assets/masterpages/Manual_Keyword_Page.htt" /> | ||
</head> | ||
<body> | ||
<h1><span data-field="title" data-format="default">dbg_button</span></h1> | ||
<p>This function creates a button control within the current debug section. Clicking the button executes a <span data-keyref="Type_Function"><a href="../../GML_Overview/Script_Functions.htm" target="_blank">Function</a></span>.</p> | ||
<p>The current debug section is the one last created using <span class="inline3_func"><a data-xref="{title}" href="dbg_section.htm">dbg_section</a></span>.</p> | ||
<div data-conref="../../../assets/snippets/Note_Debug_Control_Single_Column.hts"> </div> | ||
<p> </p> | ||
<h4>Syntax:</h4> | ||
<p class="code"><span data-field="title" data-format="default">dbg_button</span>(label, ref[, width, height]);</p> | ||
<p> </p> | ||
<table> | ||
<colgroup> | ||
<col /> | ||
<col /> | ||
<col /> | ||
</colgroup> | ||
<tbody> | ||
<tr> | ||
<th>Argument</th> | ||
<th>Type</th> | ||
<th>Description</th> | ||
</tr> | ||
<tr> | ||
<td>label</td> | ||
<td><span data-keyref="Type_String"><a href="../../GML_Overview/Data_Types.htm" target="_blank">String</a></span></td> | ||
<td>The button text</td> | ||
</tr> | ||
<tr> | ||
<td>ref</td> | ||
<td><span data-keyref="Type_DbgRef"><a href="../Variable_Functions/ref_create.htm" target="_blank">Reference</a></span> or <span data-keyref="Type_Function_Script"><a href="../../GML_Overview/Script_Functions.htm" target="_blank">Script Function</a></span> or <span data-keyref="Type_Function"><a href="../../GML_Overview/Script_Functions.htm" target="_blank">Function</a></span></td> | ||
<td>A <span data-keyref="Type_Function"><a href="../../GML_Overview/Script_Functions.htm" target="_blank">Function</a></span> or <span data-keyref="Type_Function_Script"><a href="../../GML_Overview/Script_Functions.htm" target="_blank">Script Function</a></span> or a reference to one (created with <span class="inline3_func"><a data-xref="{title}" href="../Variable_Functions/ref_create.htm">ref_create</a></span>)</td> | ||
</tr> | ||
<tr> | ||
<td>width</td> | ||
<td><span data-keyref="Type_Real"><a href="../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td> | ||
<td><span data-conref="../../../assets/snippets/Tag_optional.hts"> </span> The width of the button in pixels</td> | ||
</tr> | ||
<tr> | ||
<td>height</td> | ||
<td><span data-keyref="Type_Real"><a href="../../GML_Overview/Data_Types.htm" target="_blank">Real</a></span></td> | ||
<td><span data-conref="../../../assets/snippets/Tag_optional.hts"> </span> The height of the button in pixels</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<p> </p> | ||
<h4>Returns:</h4> | ||
<p class="code"><span data-keyref="Type_Void">N/A</span></p> | ||
<p> </p> | ||
<h4>Example 1: Basic Use</h4> | ||
<p class="code_heading">Create Event</p> | ||
<p class="code">my_method = function()<br /> | ||
{<br /> | ||
show_debug_message("Clicked the button!"<br /> | ||
};<br /> | ||
<span data-field="title" data-format="default">dbg_button</span>("Click me!", my_method); | ||
</p> | ||
<p>The above code creates a button control in an <a href="../Asset_Management/Objects/Objects.htm">object</a>'s Create event using <span class="inline3_func"><span data-field="title" data-format="default">dbg_button</span></span>. Since no calls are made to <span class="inline3_func"><a data-xref="{title}" href="dbg_view.htm">dbg_view</a></span> or <span class="inline3_func"><a data-xref="{title}" href="dbg_section.htm">dbg_section</a></span>, the button is added to a new debug section named <span data-keyref="DebugSection_Name_Default">"Default"</span> in a new debug view named <span data-keyref="DebugView_Name_Default">"Default"</span>. Clicking the button calls a function that shows a debug message using <span class="inline3_func"><a data-xref="{title}" href="show_debug_message.htm">show_debug_message</a></span>.</p> | ||
<p> </p> | ||
<h4>Example 2: Extended Example</h4> | ||
<p class="code_heading">Script Asset</p> | ||
<p class="code">/// Script Asset<br /> | ||
<br /> | ||
function script_function()<br /> | ||
{<br /> | ||
show_message("Called the script function!");<br /> | ||
} | ||
</p> | ||
<p class="code_heading">Create Event</p> | ||
<p class="code">my_method = function()<br /> | ||
{<br /> | ||
show_message("Called the method!");<br /> | ||
}<br /> | ||
<br /> | ||
ref_to_method = ref_create(self, "my_method");<br /> | ||
ref_to_script_function_global = ref_create(global, "script_function");<br /> | ||
func = script_function;<br /> | ||
ref_to_script_function = ref_create(self, "func");<br /> | ||
<br /> | ||
dbg_section("Function Calls");<br /> | ||
dbg_button("Call the Script Function", script_function, 400);<br /> | ||
dbg_button("Call the Script Function through the Reference", ref_to_script_function, 400);<br /> | ||
dbg_button("Call the Script Function through the Reference (Global)", ref_to_script_function_global, 400);<br /> | ||
dbg_button("Call the Method", my_method, 400);<br /> | ||
dbg_button("Call the Method through the Reference", ref_to_method, 400);<br /> | ||
dbg_section("Game");<br /> | ||
dbg_button("End the Game", game_end); | ||
</p> | ||
<p>The code example above shows a variety of ways to add button controls that execute functions to the debug overlay.</p> | ||
<p>First, a script function is defined in a script asset as well as a method in an object's Create event. Then, also in the Create event, various references to the script function and to the method are created. Note that in case of <span class="inline2">ref_to_script_function</span>, you can change the function to be executed by simply assigning a new value to the instance variable <span class="inline2">func</span>. After that, two sections are added to the debug overlay. Several buttons are added to the first section, where each of them calls the script function or the method through a different path. One more button is added to the second section. Clicking this button executes the built-in function <span class="inline3_func"><a data-xref="{title}" href="../General_Game_Control/game_end.htm">game_end</a></span>, which can be called because it takes no (mandatory) arguments.</p> | ||
<p>When the code has executed, <a data-xref="{title}" href="The_Debug_Overlay.htm">The Debug Overlay</a> is shown as any call to the <span class="inline2">dbg_*</span> functions will bring up the overlay.</p> | ||
<p> </p> | ||
<p> </p> | ||
<div class="footer"> | ||
<div class="buttons"> | ||
<div class="clear"> | ||
<div>Back: <a data-xref="{title}" href="The_Debug_Overlay.htm">The Debug Overlay</a></div> | ||
<div>Next: <a data-xref="{title}" href="dbg_checkbox.htm">dbg_checkbox</a></div> | ||
</div> | ||
</div> | ||
<h5><span data-keyref="Copyright Notice">© Copyright YoYo Games Ltd. 2023 All Rights Reserved</span></h5> | ||
</div> | ||
<!-- KEYWORDS | ||
dbg_button | ||
--> | ||
<!-- TAGS | ||
dbg_button | ||
--> | ||
</body> | ||
</html> |