If I have a button
sum(7,7,21,5,"Login
sum(7,7,21,30,"Exit
sum(12,25,25,1
Then what would be my if then code to know which button I pressed and therefore what to do next?
I know its stored in Ans but whats the actual code on the If...Then

Thanks!
The easiest way is to figure it out by trial and error by looking at Ans(4). To quote the SDK:

Quote:
Ans: A four-element list is returned in Ans containing {X,Y,CLICK,TRIGGER}. [...] The value of TRIGGER indicates which hotspot in the GUI stack was clicked; its meaning is very dependent on the contents you have pushed into the GUI stack. If you pushed a GUIRWinButtons containing only an X and a GUIRButtonText, for instance, clicking the X will return TRIGGER=0, and clicking the text button will return TRIGGER=1. Scrollbars have two hotspots, so clicking the left or up arrow will return a distinct trigger from clicking the right or down arrow. You may also wish to correlate the values of {X,Y} and TRIGGER for more fine-grained detection. Generally, trial-and-error is the best (and most intuitive) way to figure out what TRIGGER values correspond to what GUI element for a particular GUI stack configuration.


In your case, Ans(4) == 0 for Login, and Ans(4) == 1 for Exit. Of course, I assume you have at least a GUIRSmallWin or GUIRLargeWin before that, and if you have things like GUIRWinButtons and other clickable things, then 0 and 1 will be 1 and 2, or 2 and 3, etc. Makes sense?
ohhh okay I thought it was coordinate based, so haha my mistake. Thanks KermM I'll try that now in my new game. Very Happy
0rac343 wrote:
ohhh okay I thought it was coordinate based, so haha my mistake. Thanks KermM I'll try that now in my new game. Very Happy
You can do the checking via coordinates with Ans(1) and Ans(2), but since Doors CS already does it for you, there's no real reason not to use Ans(4). Smile
Gotcha thanks!
0rac343 wrote:
Gotcha thanks!
Is everything all working with it, then? I hope we get to see some screenshots soon, and of course please continue to ask DCSB Libs-related questions here or elsewhere.
Yes I have the clicking down now. So I can now continue with the development of the actual Arena game!
0rac343 wrote:
Yes I have the clicking down now. So I can now continue with the development of the actual Arena game!
That sounds awesome. I think you already posted a Your Projects topic about this, so I hope you'll bump it every once in a while with progress reports.
haha I will soon!
0rac343 wrote:
haha I will soon!
Excellent. Getting slightly more on-topic, do you feel that the DCSB Libs documentation about using the GUI stack in the SDK is insufficient? I'd be happy to accept any suggestions or even any sections that you or others would be interested in writing.
well actually looking through all the pages of the pdf file, I would appreciate if there was more in depth examples on the DCSlib mouse/button interaction.
0rac343 wrote:
well actually looking through all the pages of the pdf file, I would appreciate if there was more in depth examples on the DCSlib mouse/button interaction.
Fair enough, then please let me know what I can tell you more about. Smile
If I use


Code:
call     GUIMouse


then, I have the other routines that the buttons point to when clicked, can I ret to go back to the call GUIMouse? Or do I have to jump somewhere?

Also, what is the deal with FileSaveAs? Can I create an empty file, except for the header, then dynamically edit it?
First question: No. I recommend you read the documentation (http://dcs.cemetech.net/index.php?title=GUIMouse); in particular:
Quote:
RenderGUI is automatically called from GUIMouse. If you're going to be using GUIMouse, don't bother with RenderGUI first.
You need to call GUIMouse, but when control is returned to your program, the stack will be in a condition as if you jped to GUIMouse. Keep that in mind!!
You must call ResetAppPage as the very first instruction anywhere in your program to which GUIMouse might jump.


You can create an empty file and dynamically edit it; just be sure you know what you're doing. Smile
KermMartian wrote:
First question: No. I recommend you read the documentation (http://dcs.cemetech.net/index.php?title=GUIMouse); in particular:
Quote:
RenderGUI is automatically called from GUIMouse. If you're going to be using GUIMouse, don't bother with RenderGUI first.
You need to call GUIMouse, but when control is returned to your program, the stack will be in a condition as if you jped to GUIMouse. Keep that in mind!!
You must call ResetAppPage as the very first instruction anywhere in your program to which GUIMouse might jump.



Understood. I suppose that I can push 'sp' onto the stack, call GUIMouse, then at the end, pop 'sp'.
No, that's a terrible idea. Why would you do that?


Code:
    ...stuff...
    call GUIMouse
;execution never reaches here

ButtonTargetLabel:
    call ResetAppPage
    ...more stuff at the same level as the previous stuff...
Because what I really want to do is this...


Code:

...stuff...
call   GUIMouse
...start from here

ButtonTargetLabel1:
call   ResetAppPage
...more stuff...
return to "start from here"
That doesn't make much sense, though, to me. In what case could it fall through without going to a label associated with something to click? Are you thinking of a mousehook that runs like a mouse interrupt?
Hmmm. To be honest, now that I think of it I'm not sure what I wanted to accomplish. I'll have to look at the code again and get back to you.

Edit: I'm officially an idiot. Never mind on that question.
ACagliano wrote:
Hmmm. To be honest, now that I think of it I'm not sure what I wanted to accomplish. I'll have to look at the code again and get back to you.

Edit: I'm officially an idiot. Never mind on that question.
No problem, it happens. Smile Glad you have it all straight in your mind now, though.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement