Jump to content

Archived

This topic is now archived and is closed to further replies.

geoffco

XML Mouse Clicks

Recommended Posts

Hi,Please could somebody tell me how to code a mouse area (for example, on an AP Altitude selector) so that left clicks change a variable by units and right clicks change the variable by tens - Just for to make it really perfect, I would also like to have the wheel adjust the variable... I have the following but it does very strange things!

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

Thanks for any help - this is really confusing me now because it seems like it should be really simple :)Geoff

Share this post


Link to post
Share on other sites

Sorry, I was tired when I wrote that - here is more detail:It's for a 2D cockpit gauge in FS2004. The code I posted above does activate the different mouse buttons, but they all seem to increment (or decrement) by 400 ft - I suppose my question, in it's simplest form, is how do I set the amount of increase / decrease on the different types of click?If somebody could point me in the direction of some working examples or tutorials (which actually explain the sections) then that would be great too...Thanks,Geoff

Share this post


Link to post
Share on other sites

Geoff,Usually if a click section has a "increase" section and right next to it (next area) has a "decrease" section then it is almost 100% implied by FS to include mouse wheel, at least from my past testing. The mousewheel function usually isn't activated until at least one of the click areas have been clicked and focus is on that area. MIleage may vary.The following code adjusts Altitude hold by 100® & 1000(L) feet. To make it metric use the varibles below..(A:AUTOPILOT ALTITUDE LOCK VAR, meters) (>K:AP_ALT_VAR_SET_METRIC)You must use "scmp" "string compare" to isolate which mouse function is being used and trap it through code.This code has not been tested as is, ( has been used before though ) my FS computer blew up and I am writing this from memory on my netbook. Hope this helps,Roman

<Mouse> <Area Name="Decrease Altitude" Left="0" Width="18" Top="0" Height="34"> <Cursor Type="DownArrow"/> <Click Repeat="Yes" Kind="LeftSingle+RightSingle">(M:Event) 'RightSingle' scmp 0 == if{ (A:AUTOPILOT ALTITUDE LOCK VAR, feet) 100 - 0 max (>K:AP_ALT_VAR_SET_ENGLISH) } els{ (A:AUTOPILOT ALTITUDE LOCK VAR, feet) 1000 - 0 max (>K:AP_ALT_VAR_SET_ENGLISH) } </Click> </Area><Area Name="Increase Altitude" Left="19" Width="18" Top="0" Height="34"> <Cursor Type="UpArrow"/> <Click Repeat="Yes" Kind="LeftSingle+RightSingle">(M:Event) 'RightSingle' scmp 0 == if{ (A:AUTOPILOT ALTITUDE LOCK VAR, feet) 100 + (>K:AP_ALT_VAR_SET_ENGLISH) } els{ (A:AUTOPILOT ALTITUDE LOCK VAR, feet) 1000 + (>K:AP_ALT_VAR_SET_ENGLISH) } </Click> </Area></Mouse>

Share this post


Link to post
Share on other sites

Hi Roman! Have you got something against using "tabs" to indent the script? It sure makes it easier to read and understand at a glance... :(

<Click Repeat="Yes" Kind="LeftSingle+RightSingle">     (M:Event) 'RightSingle' scmp 0 ==           if{ (A:AUTOPILOT ALTITUDE LOCK VAR, feet) 100 - 0 max               (>K:AP_ALT_VAR_SET_ENGLISH) }           els{ (A:AUTOPILOT ALTITUDE LOCK VAR, feet) 1000 - 0 max                (>K:AP_ALT_VAR_SET_ENGLISH) } </Click> 

Share this post


Link to post
Share on other sites
Geoff,Usually if a click section has a "increase" section and right next to it (next area) has a "decrease" section then it is almost 100% implied by FS to include mouse wheel, at least from my past testing. The mousewheel function usually isn't activated until at least one of the click areas have been clicked and focus is on that area. MIleage may vary.The following code adjusts Altitude hold by 100® & 1000(L) feet. To make it metric use the varibles below..(A:AUTOPILOT ALTITUDE LOCK VAR, meters) (>K:AP_ALT_VAR_SET_METRIC)You must use "scmp" "string compare" to isolate which mouse function is being used and trap it through code.This code has not been tested as is, ( has been used before though ) my FS computer blew up and I am writing this from memory on my netbook. Hope this helps,Roman
<Mouse> <Area Name="Decrease Altitude" Left="0" Width="18" Top="0" Height="34"> <Cursor Type="DownArrow"/> <Click Repeat="Yes" Kind="LeftSingle+RightSingle">(M:Event) 'RightSingle' scmp 0 == if{ (A:AUTOPILOT ALTITUDE LOCK VAR, feet) 100 - 0 max (>K:AP_ALT_VAR_SET_ENGLISH) } els{ (A:AUTOPILOT ALTITUDE LOCK VAR, feet) 1000 - 0 max (>K:AP_ALT_VAR_SET_ENGLISH) } </Click> </Area><Area Name="Increase Altitude" Left="19" Width="18" Top="0" Height="34"> <Cursor Type="UpArrow"/> <Click Repeat="Yes" Kind="LeftSingle+RightSingle">(M:Event) 'RightSingle' scmp 0 == if{ (A:AUTOPILOT ALTITUDE LOCK VAR, feet) 100 + (>K:AP_ALT_VAR_SET_ENGLISH) } els{ (A:AUTOPILOT ALTITUDE LOCK VAR, feet) 1000 + (>K:AP_ALT_VAR_SET_ENGLISH) } </Click> </Area></Mouse>

Thanks very much for that, I now understand how it works (and what I had omitted). It's working perfectly and I can move on with my project.Cheers,Geoff

Share this post


Link to post
Share on other sites

Bill,I know... But this netbook doesn't have a "TAB" ,, -or- just cannot find it. LOL. I Know! my FS XML does not comply according to an IDE formatted code. :( But it "does"??? work?Geoff, glad you got something out of it - good luck and happy coding on your project, there's always someone here to help.I miss my F-8F & writing really weird code and testing in the "Bear-Kitty"Haven't flown in a while & kinda missing it.Roman

Share this post


Link to post
Share on other sites
Bill,I know... But this netbook doesn't have a "TAB" ,, -or- just cannot find it. LOL. I Know! my FS XML does not comply according to an IDE formatted code. :( But it "does"??? work?
Actually, when using the forum's editor, I simply insert five spaces to simulate a TAB key... :Big Grin:For the sake of those who don't visit the FS-Developer forums, here is a copy of a post made there in response to the same basic thread:
Thanks very much for the help' date=' 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[/quote']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.
<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:

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

Share this post


Link to post
Share on other sites

×
×
  • Create New...