Howto:Adding a canvas to a GUI dialog: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
No edit summary
mNo edit summary
Line 29: Line 29:
</syntaxhighlight>
</syntaxhighlight>
You can then use Nasal to animate your canvas and draw graphics etc.
You can then use Nasal to animate your canvas and draw graphics etc.
<syntaxhighlght lang="xml">
<?xml version="1.0"?>
<PropertyList>
  <name>fgplot</name>
  <modal>false</modal>
  <layout>vbox</layout>
  <text>
    <label>FGPlot</label>
  </text>
  <group>
    <layout>hbox</layout>
    <halign>fill</halign>
    <default-padding>10</default-padding>
    <empty><stretch>true</stretch></empty>
    <empty><stretch>true</stretch></empty>
<canvas>
              <name>fgplot</name>
              <valign>fill</valign>
              <halign>fill</halign>
              <stretch>true</stretch>
              <pref-width>600</pref-width>
              <pref-height>400</pref-height>
<nasal>     
<!--
    this is the Nasal/canvas section where you can run your own Nasal code
    to access the canvas section
-->
<load><![CDATA[
# you can add your canvas-specific code here
var my_canvas = canvas.get( cmdarg() ); # this will get a handle to the parent canvas:
print("Hello world from the embedded canvas section!\n");
]]>
</load>
</nasal>
</canvas>
    <button>
      <legend>Exit</legend>
      <equal>true</equal>
      <key>Esc</key>
      <binding>
        <command>dialog-close</command>
      </binding>
    </button>
    <empty><stretch>true</stretch></empty>
  </group>
</PropertyList>
</syntaxhighlight>

Navigation menu