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

P3D v4 [XML] polygonal MouseAreas?

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Well Hello there...

Is it possible to create non-rectangular mouseareas in a XML gauge?
 
Messages
840
Country
indonesia
To simulate a circular area I've used multiple rectangles to approximate the circle.
The more rectangles you use the nearer to a circle it gets.
 

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Chris,
Yeah, I was afraid that this is the answer... I want to display a front-view schematic of the Wasp engine with the cylinders and valves having their unique mouseareas. 9 cylinders with 3 clickspots each and except for the no. 1 cylinder, they're all at a different angle.

I think I'll rather find a different way to display my information then, maybe lining up the cylinders separately?!
 

tgibson

Resource contributor
Messages
11,324
Country
us-california
Put a red dot on the click spot and tell people to click the dot? If your parts are labeled put the click spot on top of the label?
 

Vitus

Resource contributor
Messages
1,480
Country
newzealand
Put a red dot on the click spot and tell people to click the dot? If your parts are labeled put the click spot on top of the label?
Generally a good idea, however it would mean adding an additional design feature not used in other parts of the gauge.

That's quite a nifty solution, thanks for pointing this out! It's essentially calculating a line across the rectangle and then checking on which side of the line the cursor is. The only downside for this particular problem is that the shape of the mouse cursor could potentially turn out the wrong one.
 
Messages
531
Country
france
I am an eternal beginner in XML, I hate it for programming. When you program a gauge in C/C++, you can define a rectangular clickable area, then you can get the X,Y coordinates of the mouse click within this area. You can then determine if the click is in or out a circular zone, with simple calculation.
Can't you do the same in XML? Is there a way to get the X,Y coordinates of the mouse click in the clickable area?
 
Messages
19
Country
unitedkingdom
For the benefit of future searchers - Eric is right. The Cartesian equation of a circle is your friend for circular mouse areas and is more than do-able in XML. Radius and bearing check parameters could be employed if a single mouse area is needed, but with multiple offset click points, but I'd be hard pressed to describe this as any more elegant (or, crucially, readable) as having well formatted separate mouse areas (in XML, at least).
 
Messages
1,564
Country
thailand
Is there a way to get the X,Y coordinates of the mouse click in the clickable area?

Yes, as the previous response from MIL-STD states. (M:X) and (M:Y) return the position of the mouse cursor once it is clicked and from there, the within-a-circle test can be computed and the desired mouse click script executed based on pass/fail.

The trick is, how would one get the cursor to change cursor type from pointer to finger when it is simply over the desired circular clickable area, but before it is clicked? To have a complete solution for a circular or other non-rectangular mouse area, I think you want that feature, too. If we could get (M:X) and (M:Y) just by moving the mouse around, but without clicking it, something could be hacked together to do this, but I'm not sure that is possible in XML.

In an interesting related thread, Roman Stoviak discussed mouse-over hover, but the underlying assumption was that the live click area is rectangular, defined by Top, Left, Width, Height.

Anyway, if anyone knows how to do this, I'm sure it's Roman.

Bob
 
Messages
440
Country
us-wisconsin
Hey Bob...
Thanks for the challenge! An excellent way to start the day after reading some (stopped here) of the morning "news". ;)
Worked better than any coffee blend known to man. :stirthepo :coffee:
The basic premise works. Only drawback is that it "seems" that this will negate any use of a tooltip, just can't get it to show. (don't have any more time to test)
The big problem will be the cartesian math calculations for the area of a polygon - way out of my league. :banghead:
Working code example below.

ex.jpg

XML:
<Gauge Name="possible mouse shape workaround" version="1.0">
 
    <Macro Name="Output">L:Calc_out@1, bool</Macro>
 
    <Macro Name="Turn_On_Child">
        <!-- @1 = mouse X position,  @2 = mouse Y position, @3 = suffix of L:var -->
     
        @1 128 - sqr @2 128 - sqr + abs 15129 &lt; if{ 1  (>@Output(@3)) }  
     
        <!-- just for test digit display -->
        @1 (>G:Var1)
        @2 (>G:Var2)
    </Macro>
 
    <Macro Name="Turn_Off_Child">
        <!-- @1 = mouse X position,  @2 = mouse Y position, @3 = suffix of L:var -->
     
        @1 128 - sqr @2 128 - sqr + abs 15129 &gt; if{ 0  (>@Output(@3)) }  
     
        <!-- just for test digit display -->
        @1 (>G:Var3)
        @2 (>G:Var4)
    </Macro>
 
    <Element Name="Parent Mouse Area Visual">
        <Rectangle Width="256" Height="256" FillColor="Blue" Bright="Yes"></Rectangle>
    </Element>
 
    <Element Name="Child Activated Area Visual">
        <Position X="0" Y="0"/>
            <Element Name="Off">
                <Visible>(@Output(1)) !</Visible>
                    <Circle Radius="123" LineWidth="5" Color="Red" FillColor="Blue"/>
            </Element>
         
            <Element Name="On">
                <Visible>(@Output(1))</Visible>
                    <Circle Radius="123" LineWidth="5" Color="Red" FillColor="White"/>
            </Element>
    </Element>
 
    <Element Name="Test Display">
        <FormattedText X="256" Y="20" Font="Arial" Color="Yellow" FontSize="14" FontWeight="800" Bright="Yes">
            <String>%\{tabs=5L,251R}%Parent = %((G:Var1))%!d!, %((G:Var2))%!d!%\t%Child = %((G:Var3))%!d!, %((G:Var4))%!d!%</String>
        </FormattedText>
    </Element>
 
    <Mouse>
 
        <!-- parent #1 -->
        <!-- rectangular area that engulfs the circle or needed activate area  -->
        <Area Name="Parent Sensing Area" Left="0" Top="0" Width="256" Height="256">
     
            <!-- no cursor -->
            <Cursor Type="None"/>
            <!-- no clicks available -->
            <Click Kind="Move+Leave">
         
                <!-- send to macro to calculate if in area, return 0 or 1 in L:var based on them -->            
                (M:Event) 'Move' scmp 0 == if{ @Turn_On_Child((M:X), (M:Y), 1) }
             
                <!-- extra insurance to deactivate child if mouse left rectangle area -->
                (M:Event) 'Leave' scmp 0 == if{ 0 (>@Output(1)) }
             
            </Click>        
        </Area>
     
        <!-- child #1 -->
        <!-- rectangular area same size as parent -->
        <!-- calculations in macro determine to turn off, IE calculated shape -->    
        <Area Name="Child Click Area" Left="0" Top="0" Width="256" Height="256">
         
            <!-- turn child area off if inside in defined area in macro -->
            <Visible>(@Output(1))</Visible>
            <Tooltip ID="">%HEY!! IT WORKS! :)%</Tooltip>
            <Cursor Type="Hand"/>
            <Click Kind="LeftSingle+Move+Leave">
         
                <!-- send to macro to calculate if in area, return 0 or 1 in L:var based on them -->            
                (M:Event) 'Move' scmp 0 == if{ @Turn_Off_Child((M:X), (M:Y), 1) }
             
                <!-- extra insurance to deactivate child if mouse left rectangle area -->
                (M:Event) 'Leave' scmp 0 == if{ 0 (>@Output(1)) }
             
                (M:Event) 'LeftSingle' scmp 0 == if{
                    <!-- DO MY STUFF -->
                }
            </Click>        
        </Area>
     
    </Mouse>
</Gauge>
 
Last edited:

Luka

Resource contributor
Messages
212
Country
serbia
An example for gtx-330 Pover-keys.
Note that here are two mouse areas in the same place. One is visible when the cursor is above one of the buttons (Cursor Type="Hand"), and the other without a visible cursor.

Code:
<Macro Name="MouseCX">46</Macro>
<Macro Name="MouseCY">46</Macro>
<Macro Name="MouseR1">42</Macro>
<Macro Name="MouseR2">23</Macro>
<Macro Name="MouseR3">16</Macro>

<Comment>
    @MouseCX, CY - center
    @MouseR1, R2 - outer/inner radius
    @MouseR3 - key Alt
    L:MouseX,Y - mouse coordinates (relative to CX/CY)
    L:MouseD,A - distance and angle (relative to CX/CY)
    L:MouseP - active key (0 - none, 1 - key On, 2 - key Off, 3 - key Stby, 4 - key alt
</Comment>

<Macro Name="GetMouseCoordinates">
    (M:X) @MouseCX - (>L:MouseX,enum) (M:Y) @MouseCY - (>L:MouseY,enum)
    (L:MouseX,enum) sqr (L:MouseY,enum) sqr + sqrt (>L:MouseD,enum)
    (L:MouseX,enum) (L:MouseY,enum) /-/ atg2 180 * pi / (>L:MouseA,enum)
    (L:MouseD,enum) @MouseR1 > if{ 0 (>L:MouseP,enum) }
    els{
        (L:MouseD,enum) @MouseR2 >
        if{
            -30 30 (L:MouseA,enum) rng if{ 1 (>L:MouseP,enum)    (* Key ON *) }
            els{
                90 150 (L:MouseA,enum) rng if{ 2 (>L:MouseP,enum)    (* Key OFF *) }
                els{
                    -150 -90 (L:MouseA,enum) rng if{ 3 (>L:MouseP,enum)    (* Key STBY *) }
                    els{ 0 (>L:MouseP,enum) } } } }
        els{
            (L:MouseD,enum) @MouseR3 > if{ 0 (>L:MouseP,enum) }
            els{ 4 (>L:MouseP,enum)    (* Key ALT *) } } }
</Macro>

<Mouse>
    <Area Name="Cursor Off" Left="53" Top="10" Width="93" Height="93">
        <Visible>(L:MouseP,enum) 0 ==</Visible>
        <Cursor Type="None"/>
        <Click Kind="Move">
            @GetMouseCoordinates
            0 (>L:KeyPress,enum)
        </Click>
    </Area>
    <Area Name="Cursor On" Left="53" Top="10" Width="93" Height="93">
        <Visible>(L:MouseP,enum) 0 !=</Visible>
        <Cursor Type="Hand"/>
        <Tooltip>%('Key ALT' 'Key STBY' 'Key OFF' 'Key ON' '' 5 (L:MouseP,enum) case)%!s!</Tooltip>
        <Click Kind="LeftSingle+LeftRelease+Move">
            @GetMouseCoordinates
            (M:Event) 'LeftSingle' scmp 0 ==
            if{
                (L:MouseP,enum) 1 == if{ 1 (>L:KeyPress,enum) }
                els{
                    (L:MouseP,enum) 2 == if{ 2 (>L:KeyPress,enum) }
                    els{
                        (L:MouseP,enum) 3 == if{ 3 (>L:KeyPress,enum) }
                        els{
                            (L:MouseP,enum) 4 == if{ 4 (>L:KeyPress,enum) }
                            els{
                                0 (>L:KeyPress,enum)
            } } } } }
            (M:Event) 'LeftRelease' scmp 0 == if{ 0 (>L:KeyPress,enum) }
        </Click>
    </Area>
</Mouse>

Attached zip contains complete gauge (gaugeXX=gtx330_keys!gtx330mouse,0,0,591,153)

gtx330mouse.jpg
 

Attachments

  • gtx330_keys.zip
    74.7 KB · Views: 184
Last edited:
Top