Board index FlightGear Development Nasal

Faking enter key press

Nasal is the scripting language of FlightGear.

Faking enter key press

Postby gkick » Sun Jun 09, 2019 5:53 pm

Hi All,


how to simulate a keypress ??

The code below is executed by way of a button anywhere up in the clouds.

Code: Select all
      <binding>
          <command>nasal</command>
        <script>
         setprop("/sim/atc/freq-airport", (getprop("/sim/airport/closest-airport-id")));   
         fgcommand("dialog-show", props.Node.new({ "dialog-name" : "atc-freq-search" }));         
         </script>              
         <binding>            
      </button>

sets the property correct and opens the freq search form.
Now is there a way to simulate that the enter key was pressed to close the dialog to open the results dialog
or is there a way to open the results directly without showing the search dialog.???
Last edited by Johan G on Mon Jun 10, 2019 8:33 am, edited 1 time in total.
Reason: Added [code] tags. They can be added manually or with the [^_ ] button.
gkick
 
Posts: 106
Joined: Mon Jan 02, 2017 12:04 am

Re: Faking enter key press

Postby Gijs » Thu Jun 13, 2019 10:46 am

Hi,

This should open the results dialog with the frequencies of the closest airport:
Code: Select all
fgcommand("ATC-freq-display", props.Node.new({ "icao" : getprop("/sim/airport/closest-airport-id") }) );
fgcommand("dialog-show", props.Node.new({ "dialog-name" : "atc-freq-display" }) );

Gijs
Airports: EHAM, EHLE, KSFO
Aircraft: 747-400
User avatar
Gijs
Moderator
 
Posts: 9549
Joined: Tue Jul 03, 2007 3:55 pm
Location: Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Faking enter key press

Postby Octal450 » Thu Jun 13, 2019 4:59 pm

You can also use the <command>dialog-close</command> binding to close the current dialog. Just make sure you do that after you open the other one.

Josh
Skillset: JSBsim Flight Dynamics, Systems, Canvas, Autoflight/Control, Instrumentation, Animations
Aircraft: A320-family, MD-11, MD-80, Contribs in a few others

Octal450's GitHub|Launcher Catalog
|Airbus Dev Discord|Octal450 Hangar Dev Discord
User avatar
Octal450
 
Posts: 5601
Joined: Tue Oct 06, 2015 1:51 pm
Location: Huntsville, AL
Callsign: WTF411
Version: next
OS: Windows 11

Re: Faking enter key press

Postby gkick » Thu Jun 13, 2019 6:30 pm

Thanks guys !
gkick
 
Posts: 106
Joined: Mon Jan 02, 2017 12:04 am


Return to Nasal

Who is online

Users browsing this forum: No registered users and 2 guests