• 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 Long Press Mouse Function?

Messages
10,163
Country
us-arizona
Hey all,

Does anyone have a code that will cause a 'Long Mouse Press' function?

For instance, a particular alarm goes off, and you click on a button pertaining to that system alarm, and the alarm is disarmed.

I have seen it before a couple of times. Ingenius coding. It would be an M:Event section.


Bill
 
I do not need this, no emergency. For some reason, I am thinking on this and was curious how it would be done...
 
There are many ways to skin this cat.. Here's a non-tested hypothetical.
This should work as long as there is no press repeat needed for the short or long click command. (would have to do it another way)

XML:
<Mouse>
<Area Left="XX" Top="YY" Width="XX" Height="YY">
<Tooltip ID="">Long Click Test</Tooltip>
<Cursor Type="Hand"/>
<Click Kind="LeftSingle+LeftRelease">

<!-- ON INITIAL CLICK DOWN ADD 3 SECONDS TO THE CURRENT TIME -->
(M:Event) 'LeftSingle' scmp 0 == if{ (P:ABSOLUTE TIME, seconds) 3 + (>L:My_Click_Timer, number) }

<!-- ON THE SUBSEQUENT RELEASE OF CLICK AREA COMPARE THE CURRENT TIME TO THE PREVIOUS L:VAR -->
<!-- BASED ON THE COMPARISON DO EITHER A SINGLE QUICK CLICK COMMAND OR A COMMAND REQUIRING THE LONG PRESS -->
<!-- RESET THE WHOLE THING REGARDLESS -->
(M:Event) 'LeftRelease' scmp 0 ==  if{

<!-- COMPARE CURRENT TIME TO L:VAR, IF GREATER, THEN IT'S A LONG PRESS, ELSE IT'S A SHORT PRESS -->
(P:ABSOLUTE TIME, seconds) (L:My_Click_Timer, number) &gt=; if{ (* DO THE LONG PRESS COMMAND *) }
els{ (* DO THE SHORT PRESS COMMAND *) }

<!-- THE RESET -->
0  (>L:My_Click_Timer, number)
}
</Click>
</Area>
</Mouse>
 
Last edited:
Thanks Roman. Its not an easy subject.

If you could measure the click time, which you would be doing by starting the timer, then....
if.... 2 seconds and greater then (* DO PLAN B *)
els.... (* DO PLAN A *)

So perhaps the click would be a timer.. then if/els is based on that. The button is simply a timer.

Your reset is simply left release then? But you need the release to gauge the time amount...

argh...
 
The running clock of the sim will become the timer once the initial click down ▼ is made, a reference is created. (P:ABSOLUTE TIME, seconds) 3 + (>L:My_Click_Timer, number)
The 3 is the timer amount. Adjust as wanted.

For an example, on the down click ▼ the current time of the sim is 12:00:00, therefore (L:My_Click_Timer, number) = 12:00:03 .

The following can happen on the click release ▲ depending on when it was released :
  1. If the the click is released ⅓ second later. Time = 12:00:00.333, L:Var = 12:00:03. The current time is not greater or equal to the the L:Var - Do the short duration click command. els{ }
  2. If the the click is released one second later. Time = 12:00:01, L:Var = 12:00:03. The current time is not greater or equal to the the L:Var - Do the short duration click command. els{ }
  3. If the the click is released two seconds later. Time = 12:00:02, L:Var = 12:00:03. The current time is not greater or equal to the the L:Var - Do the short duration click command. els{ }
  4. If the the click is released three seconds later. Time = 12:00:03, L:Var = 12:00:03. The current time is greater or equal to the the L:Var - Do the long duration click command. if{ }
The reset.... Hmmm. After thinking about it, I think that is overkill and not necessary.
Nothing can be done until the initial click down ▼ , where the L:Var gets updated. Then gets compared on the subsequent click up ▲.

2 notes:
  1. Again, repeat type code cannot be used in the if{ } or the els{ } OR as a <Click> attribute. ex.. ( <Click Repeat="Yes">, must be "No" )
  2. Also.. If the sim is paused only the short click will be performed.
2 small drawbacks, but in either case, not major.

Another note.. The same L:Var can be used in each and every one of the clickspots needed with timers. One cannot click 2 spots at the same time.. :eek:
 
Last edited:
That is brilliant. I didnt know that about timers.

You wrote;
Another note.. The same L:Var can be used in each and every one of the clickspots needed with timers. One cannot click 2 spots at the same time.. :eek:

lolol... Cool. That would simplify things.

You wrote;
2 notes:
  1. Again, repeat type code cannot be used in the if{ } or the els{ } OR as a <Click> attribute. ex.. ( <Click Repeat="Yes">, must be "No" )
So basically, you would have a separate code block that manages this input. Something that says 'this has been clicked, was clicked for 1 second and less then, do this. Then it would also shut down the timer.
 
This is getting deep.. :stirthepo o_O

Unsure, a hypothesis. Basically when <Click Repeat="Yes"> is used, the time between the initial click (w/ subsequent hold) and the time difference until it starts to repeat is hard coded either in the sim or in Windows itself.

Here is some code that should work with an adjustable repeat delay, in this case, 5 seconds. Again not tested in sim.
This has a repeat and works as such -
1) On the initial click and hold for the first 5 seconds it will add 1° to the AP heading bug - repeating while held.
2) After 5 seconds of a click hold it will add 15° :rolleyes: to the AP heading bug - repeating while held. (Why 15° ? - just for kicks)
3) A right click was provided to sync current heading to the AP heading bug.

In this case the reset must be used. The same L:Var can be used for any click spot.
XML:
<Mouse>
<Area Left="XX" Top="YY" Width="XX" Height="YY">
<Tooltip ID="">Long Click Test</Tooltip>
<Cursor Type="Hand"/>
<Click Kind="LeftSingle+LeftRelease+RightSingle" Repeat="Yes">

<!-- ON INITIAL CLICK DOWN ADD 5 SECONDS TO THE CURRENT TIME "ONLY" IF IT HASN'T BEEN SET BEFORE -->
(M:Event) 'LeftSingle' scmp 0 == (L:My_Click_Timer, number) 0 == and if{ (P:ABSOLUTE TIME, seconds) 5 + (>L:My_Click_Timer, number) }

<!-- CURRENT TIME IS GREATER THAN THE 5 SECONDS PLUS THE TIME WHEN THE MOUSE WAS INITIALLY CLICKED -->
<!-- IN THIS EXAMPLE IT ADDS 15 DEGREES TO THE AP HEADING BUG, FOR KICKS. WITH REPEAT -->
(P:ABSOLUTE TIME, seconds) (L:My_Click_Timer, number) &gt=; if{ (A:AUTOPILOT HEADING LOCK DIR, degrees) 15 + dnor (>K:HEADING_BUG_SET) }

<!-- CURRENT TIME IS LESS THAN THE 5 SECONDS PLUS THE TIME WHEN THE MOUSE WAS INITIALLY CLICKED -->
<!-- IN THIS RESULT IT ADDS 1 DEGREE TO THE AP HEADING BUG, WITH REPEAT -->
els{ (A:AUTOPILOT HEADING LOCK DIR, degrees) 1 + dnor (>K:HEADING_BUG_SET) }

<!-- RESET THE WHOLE THING REGARDLESS, A MUST HAVE IN THIS SITUATION -->
(M:Event) 'LeftRelease' scmp 0 ==  if{ 0 (>L:My_Click_Timer, number) }

<!-- RIGHT CLICK, SET CURRENT HEADING TO AP HEADING BUG -->
(M:Event) 'RightSingle' scmp 0 ==  if{ (A:Plane heading degrees magnetic, degrees) (&gt;K:HEADING_BUG_SET) }

</Click>
</Area>
</Mouse>
 
Nice... So simple. This is a tripple clicker! My goodness man. Exotic....

So, you can normally just let a clock run and not worry about it, not worry about turning it off? Just curious.

I guess thats the same as a gauge string looking for something that turns on, like 'flaps down 5 deg or more', etc. Its always running, always looking.


Bill
 
Hi,

Yes, setting L: values takes very little overhead and I don't worry about them. Not true for K: event flooding though, as you know.
 
Back
Top