• 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.

FS2004 How to "activate"/"deactivate" mouse click areas

Messages
130
Country
france
Hello,

I want to create a status panel with several pages for an aircraft.

This is an xml gauge that displays aircraft parameters as text elements on a black background, and allows to change some parameters by mouse clickspots.

I believe I can define which page/elements to display with <Visibility> tags.

But how can I "activate"/"deactivate" mouse click areas on the different pages ?

I don't want mouse click areas from say page one to be active on page two.

I hope I'm being clear. :o
Thanks in advance for any advice !

Gunter
 
Gunter,

This should do it..

<Area>
<Visible> Code to activate mouse area </Visible>
<Click> Do something </Click>
</Area>

Roman
 
Excellent!
That perfectly answers my question.
I didn't know one could use "visibility" tags in an area.
Never even considered trying it out. Been taking things too literal ... :p
Thanks a lot!
Gunter
 
Oh my yes! I've used mouse area <Visibility> tags in some very complex "softkey" menu systems in my custom G1000 PFD/MFD units.

Of course, you can also use (condition,unit) if{ do something } to achieve the same goal, but frankly <Visibility> is much easier to work with!

One of my latest "fun projects" was scripting the remote control unit for the G1000 Perspective version, on which the two ganged knobs are used for "Page" and "Group" selection, Com1 tuning, Com2 tuning, Com1 Stby tuning, Nav2 Stby tuning, and Transponder setting!
 
Last edited:
Is it possible to achieve this using C++ rather than XML?

I have read another thread which suggested using 'if' conditionals around the MOUSE_CHILD_FUNCTIONS but when doing this I get an error stating that it expected an expression.

Thanks
Av8tr
 
Is it possible to achieve this using C++ rather than XML?
I have read another thread which suggested using 'if' conditionals around the MOUSE_CHILD_FUNCTIONS but when doing this I get an error stating that it expected an expression.
Thanks
Av8tr

Its a little more tedious. You will have to use and 'if' or 'switch' statement in the mouse callback function to allow the single function to handle different situations.
Note that you can specify variables for the tooltip text and mouse cursor items in the MOUSE_PARENT and MOUSE_CHILD_FUNCTION.

Doug
 
Another handy trick is to define a single mouse rectangle with the normal cursor for the entire gauge. Then you can decide based on the pix_point coordinates which areas will be clickspots dynamically. You can also change the cursor by capturing the current cursor in use using GetCursor, saving it to a HCURSOR var so you can change back, and loading your own cursor using LoadCursor, then displaying it SetCursor.
 
Thanks both for your very helpful replies. After a day of fiddling I managed to get it all working correctly!

Av8tr
 
1) When does a particular post become archived and how would one know? 2) Is it possible for a right and left mouse click to use the same area? I want to be able to use the entire gauge background as the area to right or left mouse click to increment or decrement a value; if so, how? Finally, how does one determine the center <Axis> of a text so it can rotate as desired?
 
Last edited:
This code seems to work OK; modify it for your gauge. Remove the Visible section if not needed:

XML:
    <Area Left="370" Top="585" Width="80" Height="50">
        <Visible>
            (L:Pwr_Switch_set, bool) 1 ==
        </Visible>
        <Tooltip>Line Voltage: %((L:Voltage_set, number))%{case}%{:1}20%{:2}115%{end} Volts</Tooltip>
        <Cursor Type="Hand"/>
        <Click Kind="LeftSingle+RightSingle+WheelUp+WheelDown">
            (M:Event) 'WheelDown' scmp 0 ==
            (M:Event) 'LeftSingle' scmp 0 == ||
            (L:Voltage_set, number) 1 &gt; &amp;&amp;
                if{  
                    (L:Voltage_set, number) 1 - (&gt;L:Voltage_set, number)
                    }
            (M:Event) 'WheelUp' scmp 0 ==
            (M:Event) 'RightSingle' scmp 0 == ||
            (L:Voltage_set, number) 2 &lt; &amp;&amp;
                if{  
                    (L:Voltage_set, number) 1 + (&gt;L:Voltage_set, number)
                    }
        </Click>
    </Area>
 
Another example of Visibility used in a Mouse area .
It is one button contained in an MFD , it does multiple functions on a single page as well as different functions
on different pages .
Code:
    <Macro Name="Button10">(L:DAT49 mode,enum) 2 == if{ (&gt;K:NAV2_RADIO_SWAP) }
           (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 0 == and
                if{ 0 (&gt;@c:FlightPlanWaypointIndex)
                    1 (&gt;@c:FlightPlanDirectToDestination)
                    1 (@c:FlightPlanWaypointIndex) (>@c:FlightPlanDeleteDirectTo)
                    0 (@c:FlightPlanWaypointIndex) (>@c:FlightPlanDeleteWaypoint) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 0 == (L:TypEntry, enum) 0 == and and and
               if{ (L:KoalaLatitude, degrees) (&gt;@c:FlightPlanNewWaypointLatitude, degrees)
                   (L:KoalaLongitude, degrees) (&gt;@c:FlightPlanNewWaypointLongitude, degrees)
                   'RDR' (L:F111_Wpt_Sum, number) near scat (&gt;@c:FlightPlanNewWaypointIdent)           
                   (L:F111_Wpt_Sum, number) (&gt;@c:FlightPlanAddWaypoint) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 0 == (L:TypEntry, enum) 1 == and and and
               if{ 0 (&gt;@c:FlightPlanWaypointIndex)
                   (L:KoalaLatitude, degrees) (&gt;@c:FlightPlanNewWaypointLatitude, degrees)
                   (L:KoalaLongitude, degrees) (&gt;@c:FlightPlanNewWaypointLongitude, degrees)
                   'RDR' (L:F111_Wpt_Sum, number) near scat (&gt;@c:FlightPlanNewWaypointIdent)
                    1 (&gt;@c:FlightPlanDirectToDestination) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 0 == (L:TypEntry, enum) 2 == and and and
               if{ (L:KoalaLatitude, degrees) (&gt;@c:FlightPlanNewWaypointLatitude, degrees)
                   (L:KoalaLongitude, degrees) (&gt;@c:FlightPlanNewWaypointLongitude, degrees)
                   'RDR' (L:F111_Wpt_Sum, number) near scat (&gt;@c:FlightPlanNewWaypointIdent)           
                   (L:F111_Wpt_Sum, number) (&gt;@c:FlightPlanAddWaypoint)
                   (L:F111_Wpt_Sum, number) 1 + (&gt;@c:FlightPlanDeleteWaypoint) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 1 == (L:TypEntry, enum) 0 == and and and
               if{ (@c:NearestAirportCurrentICAO) (&gt;@c:FlightPlanNewWaypointICAO)           
                   (L:F111_Wpt_Sum, number) (&gt;@c:FlightPlanAddWaypoint) }                   
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 1 == (L:TypEntry, enum) 1 == and and and                   
               if{ 0 (&gt;@c:FlightPlanWaypointIndex)
                  (@c:NearestAirportCurrentICAO) (&gt;@c:FlightPlanNewWaypointICAO)
                  1 (&gt;@c:FlightPlanDirectToDestination) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 1 == (L:TypEntry, enum) 2 == and and and             
               if{ (@c:NearestAirportCurrentICAO) (&gt;@c:FlightPlanNewWaypointICAO)           
                   (L:F111_Wpt_Sum, number) (&gt;@c:FlightPlanAddWaypoint)
                   (L:F111_Wpt_Sum, number) 1 + (&gt;@c:FlightPlanDeleteWaypoint) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 2 == (L:TypEntry, enum) 0 == and and and
               if{ (@c:NearestVorCurrentICAO) (&gt;@c:FlightPlanNewWaypointICAO)           
                   (L:F111_Wpt_Sum, number) (&gt;@c:FlightPlanAddWaypoint) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 2 == (L:TypEntry, enum) 1 == and and and                   
               if{ 0 (&gt;@c:FlightPlanWaypointIndex)
                  (@c:NearestVorCurrentICAO) (&gt;@c:FlightPlanNewWaypointICAO)
                  1 (&gt;@c:FlightPlanDirectToDestination) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 2 == (L:TypEntry, enum) 2 == and and and             
               if{ (@c:NearestVorCurrentICAO) (&gt;@c:FlightPlanNewWaypointICAO)           
                   (L:F111_Wpt_Sum, number) (&gt;@c:FlightPlanAddWaypoint)
                   (L:F111_Wpt_Sum, number) 1 + (&gt;@c:FlightPlanDeleteWaypoint) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 3 == (L:TypEntry, enum) 0 == and and and
               if{ (@c:NearestNdbCurrentICAO) (&gt;@c:FlightPlanNewWaypointICAO)           
                   (L:F111_Wpt_Sum, number) (&gt;@c:FlightPlanAddWaypoint) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 3 == (L:TypEntry, enum) 1 == and and and                   
               if{ 0 (&gt;@c:FlightPlanWaypointIndex)
                  (@c:NearestNdbCurrentICAO) (&gt;@c:FlightPlanNewWaypointICAO)
                  1 (&gt;@c:FlightPlanDirectToDestination) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 3 == (L:TypEntry, enum) 2 == and and and             
               if{ (@c:NearestNdbCurrentICAO) (&gt;@c:FlightPlanNewWaypointICAO)           
                   (L:F111_Wpt_Sum, number) (&gt;@c:FlightPlanAddWaypoint)
                   (L:F111_Wpt_Sum, number) 1 + (&gt;@c:FlightPlanDeleteWaypoint) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 4 == (L:TypEntry, enum) 0 == and and and
               if{ (@c:NearestIntersectionCurrentICAO) (&gt;@c:FlightPlanNewWaypointICAO)           
                   (L:F111_Wpt_Sum, number) (&gt;@c:FlightPlanAddWaypoint) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 4 == (L:TypEntry, enum) 1 == and and and                   
               if{ 0 (&gt;@c:FlightPlanWaypointIndex)
                  (@c:NearestIntersectionCurrentICAO) (&gt;@c:FlightPlanNewWaypointICAO)
                  1 (&gt;@c:FlightPlanDirectToDestination) }
            (L:DAT49 mode,enum) 4 == (L:Display mode,enum) 1 == (L:LLAptVorNdbInt,enum) 4 == (L:TypEntry, enum) 2 == and and and             
               if{ (@c:NearestIntersectionCurrentICAO) (&gt;@c:FlightPlanNewWaypointICAO)           
                   (L:F111_Wpt_Sum, number) (&gt;@c:FlightPlanAddWaypoint)
                   (L:F111_Wpt_Sum, number) 1 + (&gt;@c:FlightPlanDeleteWaypoint) }                   
            (L:DAT49 mode,enum) 4 == (L:StandOff mode,enum) 4 == and
                if{
                (L:DistMove,nmiles) 1 - (&gt;L:DistMove,nmiles) (L:DistMove,nmiles) -1 == if{ 0 (&gt;L:DistMove,nmiles) }
                }
          (L:DAT49 mode,enum) 4 == (L:StandOff mode, enum) 2 == (L:PrecisionLevel mode,enum) 0 == and and
          (L:DAT49 mode,enum) 4 == (L:StandOff mode, enum) 2 == (L:PrecisionLevel mode,enum) 1 == and and
                or
               if{ (L:ClikLatitude, degrees) (&gt;L:RequiredWaypointLatitude, degrees)
                (L:ClikLongitude, degrees) (&gt;L:RequiredWaypointLongitude, degrees)
                 }</Macro>
    <Area Left="197" Top="94" Width="20" Height="20">
      <Cursor Type="Hand"/>
      <Click Kind="LeftSingle" Repeat="Yes">(L:DAT49 mode,enum) 3 == if{ (&gt;K:HEADING_BUG_DEC) } @Button10</Click>
    </Area>

Cheers
Karol
 
Hello tgibson. Thank you for your reply and information - I will give it a shot. Hello COBS. Thank you as well for your reply and information. Your a great XML programmer. I must admit, your code seems a bit complicated for a novice like me. In the mouse area though, I did not see a "RightSingle" option, am I missing something?
Also, any information on: Finally, how does one determine the center <Axis> of a text so it can rotate as desired?
And I need a bit of assistance on efficiency. I obtained a great gauge from Glenn Copeland called the Cockpit Commander. It allows an easy way to insert data in to various parameters like NAV1, 2 COM1, 2, Heading, etc. I've modified it so I could add other parameters. It also made it easy to use a remote computer to enter data from a touchscreen tablet (through FSUIPC). One of the parameters I added was a countdown timer. For example, I enter a 4.18 which is to be 4 minutes and 18 seconds. The following code works great but too verbose.
Note: The (L:CDTmr, enum) comes from the CpitCmdr. xml

Code:
<Element Name="Converter"><Select><Value>
(L:FD_Ctrl, bool) 1 == (L:CDTmr,enum) 0 &gt; and if{
(L:CDTmr, enum) flr 60 * (>L:FDCmdr_whole_sec, enum)
(L:CDTmr, enum) (L:CDTmr, enum) flr - 1.66666 * 60 * (>L:FDCmdr_fract_sec, enum)
(L:FDCmdr_whole_sec, enum) (L:FDCmdr_fract_sec, enum) + 1 + (>L:FDCmdr_seconds,enum)
0 (>L:CDTmr, enum) }
</Value></Select>
</Element>

For some reason, I had to add the 1 + to display (XML below) the correct value in seconds but it works just fine.

Code:
<Element><Visible>(L:FD_Ctrl, bool)</Visible><Position X="60" Y="94"/>
    <FormattedText X="58" Y="20" Font="consolas" FontSize="20" Color="#cc7755" Bright="Yes">  
    <String>%((L:FDCmdr_seconds,enum) 60 / flr 60 %)%!2d!%:%((L:FDCmdr_seconds, enum)   flr 60 % )%!02d!</String>          
     </FormattedText>
</Element>

Any suggestion with an explanation would be helpful. Thank you.
 
Also, any information on: Finally, how does one determine the center <Axis> of a text so it can rotate as desired?

Hello FlyTheSimSkies
<Axis> in my very narrow experience, is used to handle images and masks inside a gauge code. I never seen any gauge with a string rotation; (not sure if it is possible at all). Take for example the scale in a tipical HSI; of course,
it contains text; however, the text written in your image editor is a dinamic string which has been rasterized and converted into pixels. If there's a way to rotate a string in XML, I am sure Tom or Karol would've mention it in their
respectives replies to you. Karol and Tom have way more experience than me.

On the other hand, if the "text" is just a simple image; I encourage you to read all of the 6 pdf files written by Nick Pike:
http://www.fs2x.com/Tutorials.htm

The answer to your <Axis> question, is in Chapter 1. Main Body Sections, page 6.

I did not see a "RightSingle" option, am I missing something?
Watch again the code kindly provided by Tom; it already have that option enabled.
<Click Kind="LeftSingle+RightSingle+WheelUp+WheelDown">

Is it possible for a right and left mouse click to use the same area?
Yes, you can. It is very common to use the same area for a left single and/or right single clicks; the same rule applies to the mouse wheel. Furthermore, they can be combined as Tom showed us in his gauge code.
You just must to decide which combination you need LeftSingle+WheelUp to increase or rotate clockwise and RightSingle+WheelDown to decrease or rotate counter clockwise. There are very interesting combinations you can make with a mouse
with 2 or more buttons and a wheel. For example, simulate spring loaded buttons and dragable levers as well.

On the other hand, you can split an image to have one or more mouse sensitive areas and also nest them using a Parent-Child relation.

For example:
HTML:
      <Mouse>
      <!-- ADF Card Knob -->
      <!-- When an ADF signal is received, the pilot rotates the card so that the present heading is at the top of the scale.
            This results in the pointer indicating the magnetic bearing to the ADF transmitter.
            This is more intuitive and consistent with other navigational practices. -->
           
      <!-- ADF Card Heading Change Knob -->
          <Area Left="36" Top="594" Width="131" Height="131">
          <ToolTip>HDG: %((A:ADF CARD,degrees))%!03.0f!°</ToolTip>
         
              <!-- HDG DEC-->
              <Area Right="60">
                  <Cursor Type="DownArrow"/>
                  <Click Repeat="Yes">
                      <!-- This code is used instead (>K:ADF_CARD_DEC) to prevent the 10 degree jump due event overflowing induced by the autopilot-->
                      (A:ADF CARD,degrees) -- dnor (>K:ADF_CARD_SET)
                      1 (>L:Bell_407_Rotary_Click, number)
                  </Click>
              </Area>
             
              <!-- HDG INC-->
              <Area Left="66">
                  <Cursor Type="UpArrow"/>
                  <Click Repeat="Yes">
                      <!-- This code is used instead (>K:ADF_CARD_INC) to prevent the 10 degree jump due event overflowing induced by the autopilot-->
                      (A:ADF CARD,degrees) ++ dnor (>K:ADF_CARD_SET)
                      1 (>L:Bell_407_Rotary_Click, number)
                  </Click>
              </Area>
          </Area>
      </Mouse>

I hope this makes sense to you.
Sergio.
 
Last edited:
Hello antaris. Thank you for your reply. Yes text can be rotated but I have not found a "formula" as to its proper placement (Position, Axis, and FormattedText X=" " Y= " ") - other than trial and error method. Below code works to rotate the text:

Code:
<Element>    <Position X="74" Y="80"/>
    <FormattedText X="58" Y="20" Font="consolas" FontSize="20" Color="#22cc55" Bright="Yes">
     <String>%((G:Var2) 18 / 60 / flr 60 %)%!2d!%:%((G:Var2) 18 / flr 60 %)%!02d!</String>   
     <Axis X="20" Y="6"/>       
     </FormattedText>
       <Rotate>
  <Value Minimum="0" Maximum="6.28318"> (G:Var2) 18 / 10 / dgrd pi 2 / - </Value>
       </Rotate>
</Element>

Again, in COBS example:
<Click Kind="LeftSingle" Repeat="Yes">(L:DAT49 mode,enum) 3 == if{ (&gt;K:HEADING_BUG_DEC) } @Button10</Click>

I see the options but do not see the actual action for RightSingle as I mentioned above - I meant to type action instead of option.

I do have the left and mouse areas working properly based on info from above - thank you.
 
Back
Top