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

Click and hold!

Messages
131
Country
unitedstates
I need to make a button function differently if I click and hold, then if I just click.

I am thinking about having "LeftSingle" turn on a loop in a update element, and "LeftRelease" turn off that loop. If the loop isn't turned off after x amount of time, "run this code", if it is turned off before x amount of time, then "run that code"

However, I remember seeing somewhere the use of the "Leave" mouseclick, but can't find any documentation on it. Anyone got a quick run-though on how the "Leave" works?

Thanks,

DNLK
 
Daniel, the SDK only mentions the event 'Leave' with no description whatever, so your guess is as good as anyone else's. Honestly, I've never tried it.

If you initiate a unique timer on any click, or a specific click, then you can easily set up an event in a callback (an <Update> section) to detect when the timer is initiated, and when the time expires, take action. In fact, I use this sort of thing for spring toggle switches in a 3d cockpit, because frequently the cursor slips off the active area before the Release event can be detected, resulting in a stuck animation.

This is an example using modeldef.xml syntax, so the <tags> are a bit different, but the priciples are the same. This induces a 2 second delay:
Code:
<Update>
    <!-- RESET M2 TEST SWITCH -->
    (L:T38_Mode2, enum) 1 ==
    if{
      (L:IdentReset,enum) (E:local time, seconds) &gt;
    if{ }
    els{ 0 (>L:T38_Mode2, enum) }
    }
</Update>


    <MouseRect>
      <CallbackCode>
        (M:Event) 'LeftSingle' scmp 0 ==
             if{ (L:T38_Mode2, enum) ++ -1 max (>L:T38_Mode2, enum) }
        (M:Event) 'RightSingle' scmp 0 ==
             if{ (L:T38_Mode2, enum) -- 1 min (>L:T38_Mode2, enum) }
        (E:LOCAL TIME,seconds) 2 + (>L:IdentReset,enum)

        1 (>L:XMLSND1,bool)
      </CallbackCode>
    </MouseRect>

Practically, what happens is that the callback will "do nothing" for the timer length specified, then "do something" when timer expires. :D
 
Last edited:
http://msdn.microsoft.com/en-us/library/cc526953.aspx#mozTocId848419
Leave = Triggers the event when the mouse leaves the MouseRect.

and a tiny bit more on MouseRect:
http://www.wiki.fsdeveloper.com/forum/showthread.php?p=137677

Greek to me. Needs someone that knows Greek. Like Fr. Bill.... does this lead anywhere?

Cheers,

Bob

You push and hold the mouse button. If the mouse pointer scrolls outside the rectangle you've defined, then the 'Leave' event is triggered.
 
Well "Leave" won't do what I want then. Guess I'll code in my own "Hold" detection. Thanks for the replies.
 
Left-click, left-release, hold var set

Right-click to release hold

Code:
        (M:Event) 'LeftSingle' scmp 0 ==
             if{  }
        (M:Event) 'LeftRelease' scmp 0 ==
             if{ 1 (>L:T38_Hold,enum) }
        (M:Event) 'RightSingle' scmp 0 ==
            if{ 0 (>L:T38_Hold,enum) }

Left-click to set hold
Double-Left-click to release

Code:
        (M:Event) 'LeftSingle' scmp 0 ==
        if{ 1 (>L:T38_Hold,enum) }
        (M:Event) 'LeftDouble' scmp 0 ==
        if{ 0 (>L:T38_Hold,enum) }

There are many other possibilities... :D
 
Hey Bill,
remember we already talked about the "leave" flag a couple of weeks ago. ;)

Of course, Daniel is working on a 2d XML "gauge," so the "leave" flag would work, although not be useful for what he wants to accomplish.

There are some very subtle differences in techniques for 2d vs. 3d scripting. The challenge for me is to use only methods that are viable in both domains...

...since I like to recycle the scripts interchangably. IOW, I can copy/paste XML scripts directly from modeldef.xml to 2d scripts... :D
 
Doh! Silly me... note to self: first read, then post...:duck:
 
Back
Top