Canvas snippets: Difference between revisions
Jump to navigation
Jump to search
Philosopher (talk | contribs) (→Canvas Input Dialog: great idea!) |
|||
Line 2: | Line 2: | ||
{{Stub}} | {{Stub}} | ||
{{WIP}} | {{WIP}} | ||
{{Canvas Navigation}} | |||
== Creating a Canvas GUI Window == | == Creating a Canvas GUI Window == | ||
Line 19: | Line 21: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
{ | == Canvas Input Dialog == | ||
<syntaxhighlight lang="nasal" enclose="div"> | |||
# create a new InputDialog with a title, label, and a callback | |||
canvas.InputDialog.getText("Input Dialog Title", "Please enter some text", func(btn,value) { | |||
if (value) gui.popupTip("You entered: "~value); | |||
}); | |||
</syntaxhighlight> |
Revision as of 20:15, 14 September 2014
This article is a stub. You can help the wiki by expanding it. |
Work in progress This article or section will be worked on in the upcoming hours or days. See history for the latest developments. |
The FlightGear forum has a subforum related to: Canvas |
Creating a Canvas GUI Window
Note This example uses so called method chaining, if you're not familiar with the concept, please see: Method Chaining. |
# create a new window, dimensions are 320 x 160, using the dialog decoration (i.e. titlebar)
var window = canvas.Window.new([320,160],"dialog");
# adding a canvas to the new window and setting up background colors/transparency
var myCanvas = window.createCanvas().setColorBackground(1,1,1,1);
# creating the top-level/root group which will contain all other elements/group
var root = myCanvas.createGroup();
Canvas Input Dialog
# create a new InputDialog with a title, label, and a callback
canvas.InputDialog.getText("Input Dialog Title", "Please enter some text", func(btn,value) {
if (value) gui.popupTip("You entered: "~value);
});