Posted 18 August 2014 - 09:24 PM
Hey Forum,
I´ve been writing on an own button api for my future projects :)/>
I tried to make this button api object oriented as a came across this topic the last days.
Now I came to a point where I really don´t know how to go on.
In my api theres a general function that checks if a click was made on a button or not.
This function loops through a table where I save a buttons that are currently active.
But what should this function return so that my main program can toggle the button to fire the action set on the button.
I know I could easily just fire the action of the button inside by detect function but the user should be able to use one button for several purposes !
This is the code of the detect function :
Currently the function returns simply the name of the button that was triggered, but I failed to get the function from the button object just by tha name of the button.
I hope someone has an idea :)/>
Kouksi44
I´ve been writing on an own button api for my future projects :)/>
I tried to make this button api object oriented as a came across this topic the last days.
Now I came to a point where I really don´t know how to go on.
In my api theres a general function that checks if a click was made on a button or not.
This function loops through a table where I save a buttons that are currently active.
But what should this function return so that my main program can toggle the button to fire the action set on the button.
I know I could easily just fire the action of the button inside by detect function but the user should be able to use one button for several purposes !
This is the code of the detect function :
function detectClick(posX,posY)
for i=1,#button_list do
if
posX<=button_list[i][2]+#button_list[i][1] and
posX>= button_list[i][2] and
posY <= button_list[i][3]+button_list[i][4] and
posY >=button_list[i][3]
then
return button_list[i][1]
end
end
end
Currently the function returns simply the name of the button that was triggered, but I failed to get the function from the button object just by tha name of the button.
I hope someone has an idea :)/>
Kouksi44