• Which the release of FS2020 we see an explosition of activity on the forun and of course we are very happy to see this. But having all questions about FS2020 in one forum becomes a bit messy. So therefore we would like to ask you all to use the following guidelines when posting your questions:

    • Tag FS2020 specific questions with the MSFS2020 tag.
    • Questions about making 3D assets can be posted in the 3D asset design forum. Either post them in the subforum of the modelling tool you use or in the general forum if they are general.
    • Questions about aircraft design can be posted in the Aircraft design forum
    • Questions about airport design can be posted in the FS2020 airport design forum. Once airport development tools have been updated for FS2020 you can post tool speciifc questions in the subforums of those tools as well of course.
    • Questions about terrain design can be posted in the FS2020 terrain design forum.
    • Questions about SimConnect can be posted in the SimConnect forum.

    Any other question that is not specific to an aspect of development or tool can be posted in the General chat forum.

    By following these guidelines we make sure that the forums remain easy to read for everybody and also that the right people can find your post to answer it.

[FS9] XML Mouse code for left or right clicks?

Messages
206
Country
unitedkingdom
Hi,

I am trying to modify some autopilot switches so that I can increment the values either with the left or right mouse buttons, with the right button providing a 10x increment. I have tried very hard to find a tutorial or resource that explains clearly how to set up more complex mouse areas, but what I end up with does not work as planned...

The example below is for the altitude selector. I want to click left to increase / decrease in 100 ft amounts and the 1000 ft amounts with the right click. (If I could get that much to work, I would also like the wheel working and the middle click to set target altitude to current altitude...). What seems to happen with this code is that both buttons do work, but the result of either click is to change the altitude by 200 ft (ie, two normal increments)! If I add some code for the wheel (another two M:Event sections) then I get the wheel also doing the same but now they all add or remove 400 ft - seems like it just does the normal "AP_ALT_VAR_INC" or "AP_ALT_VAR_DEC" operation as many times as I have mouse buttons coded... What am I doing wrong?

Code:
<Mouse>
<Area Left="0" Right="36" Top="0" Bottom="34">
    <Area Right="19">
      <Cursor Type="DownArrow"/>
          <Click Kind="LeftAll+RightAll">(M:Event) 'LeftAll' 100 (>K:AP_ALT_VAR_DEC) (M:Event) 'RightAll' 1000 (>K:AP_ALT_VAR_DEC) </Click>
    </Area>
    <Area Left="19">
      <Cursor Type="DownArrow"/>
                  <Click Kind="LeftAll+RightAll">(M:Event) 'LeftAll' 100 (>K:AP_ALT_VAR_INC) (M:Event) 'RightAll' 1000 (>K:AP_ALT_VAR_INC) </Click>
    </Area>
  </Area>

Thanks to anyone who has time to help / explain. My guess is that I've missed something obvious and silly!

Cheers,
Geoff
 
The chief problem is the way you're trying to implement the (M:Event) condition. You don't have any check value for the (M:Event) to evaluate...

In other words, every (M:Event) you have is responding to every input, not just the one input you want! :eek:

Examine the script below to see the proper syntax for an (M:Event):
Code:
      <Area Left="159" Top="322" Width="72" Height="69">
        <Cursor Type="Hand"/>
        <Click Kind="LeftSingle+RightSingle+WheelUp+WheelDown+Repeat">
          (M:Event) 'LeftSingle'  scmi 0 == if{ (>K:ATTITUDE_BARS_POSITION_DOWN) }
          (M:Event) 'RightSingle' scmi 0 == if{ (>K:ATTITUDE_BARS_POSITION_UP) }
          (M:Event) 'WheelUp'     scmi 0 == if{ (>K:ATTITUDE_BARS_POSITION_UP) }
          (M:Event) 'WheelDown'   scmi 0 == if{ (>K:ATTITUDE_BARS_POSITION_DOWN) }
        </Click>
      </Area>

I also highly recommend that you make use of the indented style of script writing, as it makes reading the script much, MUCH easier to see and understand! :cool:

Here is how one of your examples should be written:

Code:
<Click Kind="LeftAll+RightAll">
  (M:Event) 'LeftAll'  scmi 0 == if{ 100 (>K:AP_ALT_VAR_DEC) }
  (M:Event) 'RightAll'  scmi 0 == if{ 1000 (>K:AP_ALT_VAR_DEC) }
</Click>

BTW, in case you're wondering, scmi in the above is the command for "string compare and ignore case." This operation is a "subtraction" event that takes the string you've specified in the single quotes, and compares it with the string returned by the sim when a mouse button is detected. If they "match" then the result is zero, in which case the if{ } statement is executed.

I also recommend not using LeftAll or RightAll, but rather be explicit in which button you mean to be used. That will eliminate the possibility of "unintended consequences..." :teacher:
 
Last edited:
The chief problem is the way you're trying to implement the (M:Event) condition. You don't have any check value for the (M:Event) to evaluate...

In other words, every (M:Event) you have is responding to every input, not just the one input you want! :eek:

Examine the script below to see the proper syntax for an (M:Event):
Code:
      <Area Left="159" Top="322" Width="72" Height="69">
        <Cursor Type="Hand"/>
        <Click Kind="LeftSingle+RightSingle+WheelUp+WheelDown+Repeat">
          (M:Event) 'LeftSingle'  scmi 0 == if{ (>K:ATTITUDE_BARS_POSITION_DOWN) }
          (M:Event) 'RightSingle' scmi 0 == if{ (>K:ATTITUDE_BARS_POSITION_UP) }
          (M:Event) 'WheelUp'     scmi 0 == if{ (>K:ATTITUDE_BARS_POSITION_UP) }
          (M:Event) 'WheelDown'   scmi 0 == if{ (>K:ATTITUDE_BARS_POSITION_DOWN) }
        </Click>
      </Area>

I also highly recommend that you make use of the indented style of script writing, as it makes reading the script much, MUCH easier to see and understand! :cool:

Here is how one of your examples should be written:

Code:
<Click Kind="LeftAll+RightAll">
  (M:Event) 'LeftAll'  scmi 0 == if{ 100 (>K:AP_ALT_VAR_DEC) }
  (M:Event) 'RightAll'  scmi 0 == if{ 1000 (>K:AP_ALT_VAR_DEC) }
</Click>

BTW, in case you're wondering, scmi in the above is the command for "string compare and ignore case." This operation is a "subtraction" event that takes the string you've specified in the single quotes, and compares it with the string returned by the sim when a mouse button is detected. If they "match" then the result is zero, in which case the if{ } statement is executed.

I also recommend not using LeftAll or RightAll, but rather be explicit in which button you mean to be used. That will eliminate the possibility of "unintended consequences..." :teacher:

Thanks very much for the help, I now understand how it works and what I had omitted - I had not realised that the 'scmi 0 == if{}' was part of the required code but it makes sense. The clickspots are working perfectly now but I did still find one issue. The '100 (>K:AP_ALT_VAR_DEC)' vs '1000 (>K:AP_ALT_VAR_DEC)' makes no difference. However, in a very crude fix, simply adding the '(>K:AP_ALT_VAR_DEC)' ten times works well enough!

Cheers,
Geoff
 
Thanks very much for the help, I now understand how it works and what I had omitted - I had not realised that the 'scmi 0 == if{}' was part of the required code but it makes sense. The clickspots are working perfectly now but I did still find one issue. The '100 (>K:AP_ALT_VAR_DEC)' vs '1000 (>K:AP_ALT_VAR_DEC)' makes no difference. However, in a very crude fix, simply adding the '(>K:AP_ALT_VAR_DEC)' ten times works well enough!

Cheers,
Geoff

You are most welcome.

No, that won't work because you can only pass an input value to (>K:xxx_SET) type commands.

Aside from the "repeating the command 10 times" solution (which I've used for other similar circumstances), the only alternative would be to use the (>K:AP_ALT_VAR_SET_ENGLISH) event...

...in which case you would need to add or subtract 1000 from the current altitude lock variable, then pass the result to the (>K:AP_ALT_VAR_SET_ENGLISH) event.

Code:
<Click Kind="LeftAll+RightAll">
  (M:Event) 'LeftAll'  scmi 0 == if{ (>K:AP_ALT_VAR_DEC) }
  (M:Event) 'RightAll'  scmi 0 == if{ (A:AUTOPILOT ALTITUDE LOCK VAR,feet) 1000 + (>K:AP_ALT_VAR_SET_ENGLISH) }
</Click>

Since this could get "messy" real quick, this is a good place for a couple of @macros to be used:

Code:
<Macro Name="Plus1000">
    (A:AUTOPILOT ALTITUDE LOCK VAR,feet) 1000 +
</Macro>

<Macro Name="Minus1000">
    (A:AUTOPILOT ALTITUDE LOCK VAR,feet) 1000 -
</Macro>

<Click Kind="LeftAll+RightAll">
  (M:Event) 'LeftAll'  scmi 0 == if{ (>K:AP_ALT_VAR_DEC) }
  (M:Event) 'RightAll'  scmi 0 == if{ @Minus1000 (>K:AP_ALT_VAR_SET_ENGLISH) }
</Click>
 
You are most welcome.

No, that won't work because you can only pass an input value to (>K:xxx_SET) type commands.

Aside from the "repeating the command 10 times" solution (which I've used for other similar circumstances), the only alternative would be to use the (>K:AP_ALT_VAR_SET_ENGLISH) event...

...in which case you would need to add or subtract 1000 from the current altitude lock variable, then pass the result to the (>K:AP_ALT_VAR_SET_ENGLISH) event.

Code:
<Click Kind="LeftAll+RightAll">
  (M:Event) 'LeftAll'  scmi 0 == if{ (>K:AP_ALT_VAR_DEC) }
  (M:Event) 'RightAll'  scmi 0 == if{ (A:AUTOPILOT ALTITUDE LOCK VAR,feet) 1000 + (>K:AP_ALT_VAR_SET_ENGLISH) }
</Click>

Since this could get "messy" real quick, this is a good place for a couple of @macros to be used:

Code:
<Macro Name="Plus1000">
    (A:AUTOPILOT ALTITUDE LOCK VAR,feet) 1000 +
</Macro>

<Macro Name="Minus1000">
    (A:AUTOPILOT ALTITUDE LOCK VAR,feet) 1000 -
</Macro>

<Click Kind="LeftAll+RightAll">
  (M:Event) 'LeftAll'  scmi 0 == if{ (>K:AP_ALT_VAR_DEC) }
  (M:Event) 'RightAll'  scmi 0 == if{ @Minus1000 (>K:AP_ALT_VAR_SET_ENGLISH) }
</Click>

Great - thanks very much... Now I understand more about how to use simple macros, which I expect will prove useful elsewhere too!

Geoff
 
Back
Top