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 4: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 7:33 am, edited 1 time in total.
Reason: Added [code] tags. They can be added manually or with the [^_ ] button.
gkick
 
Posts: 106
Joined: Sun Jan 01, 2017 11:04 pm

Re: Faking enter key press

Postby Gijs » Thu Jun 13, 2019 9: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: 9362
Joined: Tue Jul 03, 2007 2:55 pm
Location: Amsterdam/Delft, the Netherlands
Callsign: PH-GYS
Version: Git
OS: Windows 10

Re: Faking enter key press

Postby Octal450 » Thu Jun 13, 2019 3: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
Octal450

Lead Programmer, IDG (Join our Discord!)
Download High Quality Aircraft from Octal450 Hangar
User avatar
Octal450
 
Posts: 4226
Joined: Tue Oct 06, 2015 12:51 pm

Re: Faking enter key press

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

Thanks guys !
gkick
 
Posts: 106
Joined: Sun Jan 01, 2017 11:04 pm


Return to Nasal

Who is online

Users browsing this forum: No registered users and 1 guest