Gamestudio Links
Zorro Links
Newest Posts
loading historical data 1st time
by AndrewAMD. 04/14/23 12:54
Trade at bar open
by juanex. 04/13/23 19:43
Bug in Highpass2 filter
by rki. 04/13/23 09:54
Adding Limit Orders For IB
by scatters. 04/11/23 16:16
FisherN
by rki. 04/11/23 08:38
AUM Magazine
Latest Screens
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Hecknex World
Who's Online Now
2 registered members (Grant, AndrewAMD), 911 guests, and 9 spiders.
Key: Admin, Global Mod, Mod
Newest Members
rki, FranzIII, indonesiae, The_Judge, storrealba
18919 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Multiple Buttons using 1 function #285994
08/22/09 07:31
08/22/09 07:31
Joined: May 2009
Posts: 37
S
shiznitIII Offline OP
Newbie
shiznitIII  Offline OP
Newbie
S

Joined: May 2009
Posts: 37
Hi guys! I need help on how to pass the button number if i'm using one function for several buttons in the same panel. I hope you can help me.

PANEL* charac_pan =
{
layer = 3;
pos_x = 0;
pos_y = 0;
button (10, 0, "horse1.tga", "horse1.tga", "horse3.tga", create_entity1, NULL, NULL);
button (120, 0, "pig1.tga", "pig1.tga", "pig2.tga", create_entity1, NULL, NULL);
button (230, 0, "bat1.tga", "bat1.tga", "bat2.tga", create_entity1, NULL, NULL);
flags = OVERLAY | SHOW;
}

Re: Multiple Buttons using 1 function [Re: shiznitIII] #285999
08/22/09 08:51
08/22/09 08:51
Joined: Feb 2008
Posts: 3,232
Australia
EvilSOB Offline
Expert
EvilSOB  Offline
Expert

Joined: Feb 2008
Posts: 3,232
Australia
Its built in, just not easily found in the manual.
Looking at your code you want to 'share' the funtion "create_entity1"
Do so like this. (NO changes required in panel definition)
Code:
function create_entity1(var button_number)
{
   // "button_number" now contains the button number that was pressed,
   // starting with 1. In this case "1" would be the horse button.
   ...
}




"There is no fate but what WE make." - CEO Cyberdyne Systems Corp.
A8.30.5 Commercial
Re: Multiple Buttons using 1 function [Re: EvilSOB] #286014
08/22/09 11:56
08/22/09 11:56
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
also you could/should carry the PANEL param too,

Code:
function create_entity1(var button_number, PANEL panel_id)
{
   switch(button_number){
      case 1: //button 1
         //do
      break;

      case 2: //button 2
         //do
      break;

      default: //all other buttons not already caught
      break
   }
}

hope this helps

Re: Multiple Buttons using 1 function [Re: MrGuest] #286596
08/26/09 05:23
08/26/09 05:23
Joined: May 2009
Posts: 37
S
shiznitIII Offline OP
Newbie
shiznitIII  Offline OP
Newbie
S

Joined: May 2009
Posts: 37
thanks a lot for the tip! you guys helped a lot


Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1