PDA

View Full Version : Automatically Determined Button Clicked is Self


spacesurfer
06-24-2007, 09:46 AM
Is there a way to automatically determine when a button is clicked, the program know it was that button that was clicked, meaning the button click is self, not another?

I have a jeopardy board with 25 questions. When I click on button "100" in category 1, is there a way to determine it was that button that was clicked??? If this is possible, then I don't have to edit all 25 buttons one by one to tell them this is the button that was clicked.

Right now, I'm having to edit each button's actions to tell it this is the button that was clicked. If the program can detect the button that was clicked, then I can just write a fuction that runs the actions I was performed.

srussell
06-24-2007, 09:56 AM
How about assigning a global variable to each button to use in your function?

iButton = 100

RizlaUK
06-24-2007, 10:15 AM
or you could make one function and filter the buttons (by name) within it

eg: in global functions
function DetectButtonClick(BUTTON)

if BUTTON == "Button1" then
result = Dialog.Message("Notice", "You Clicked Button 1", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end

if BUTTON == "Button2" then
result = Dialog.Message("Notice", "You Clicked Button 2", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end

if BUTTON == "Button3" then
result = Dialog.Message("Notice", "You Clicked Button 3", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end

if BUTTON == "Button4" then
result = Dialog.Message("Notice", "You Clicked Button 4", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end

if BUTTON == "Button5" then
result = Dialog.Message("Notice", "You Clicked Button 5", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end

if BUTTON == "Button6" then
result = Dialog.Message("Notice", "You Clicked Button 6", MB_OK, MB_ICONINFORMATION, MB_DEFBUTTON1);
end


end

and in each button put this:
DetectButtonClick(this)

then you can just edit the global function and leave the buttons


heres a quick example:

TJ_Tigger
06-24-2007, 11:27 AM
I don't know if this is what you are looking for but with AMS and LUA you can use the keyword this which is then populated by the name of the object that was clicked. this way you can use this keyword in a function and only write one function and have it be specific to the object clicked.

HTH
Tigg

spacesurfer
06-24-2007, 02:19 PM
@TJ Tigger

This sound more like what I'm looking for, but I fail to grasp this completely. Can you show me an example, please?

Thanks.

(Otherwise the first two posts are my only options.)

RizlaUK
06-24-2007, 02:28 PM
what tigg is referring to is exactly what my function example dose, pass the "this" to the function as a argument and it will return the button name, and then filter your code whitin the function based on the button name.

spacesurfer
06-24-2007, 08:46 PM
RizlaUK, I don't think you said the same thing TJ Tigger is talking about... although I know what you meant, it required a lot of coding.

However, I understand TJ Tigger's suggestion now. What I did is change:

result = Paragraph.GetText("CatXQuestY");

to:

result = Paragraph.GetText(this);

Now, I don't have to edit each of the 25 and define the X and Y for each one.

Thanks a lot for you help.