Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
Topic Title: Multiple Buttons with one Callback function?
Topic Summary:
Created On: 6-Oct-2004 00:06
Status: Post and Reply
Linear : Threading : Single : Branch
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
Answer This question was answered by Dirk Plaschke, on Wednesday, October 6, 2004 6:48 PM

Answer:
Hi, Shawn.

Use '==' for the condition:

// switchButton.dxl

DB db = null
DBE btn1, btn2, btn3

void cbButtons(DBE dbe)
{
if (dbe == btn1) then print "Button 1 pushed\n"
else if (dbe == btn2) then print "Button 2 pushed\n"
else if (dbe == btn3) then print "Button 3 pushed\n"
}

// main.

db = create("Buttontest")
btn1 = button(db, "Button", cbButtons)
btn2 = button(db, "Button", cbButtons)
btn3 = button(db, "Button", cbButtons)
show(db)

Dirk.
 6-Oct-2004 00:06
User is offline View Users Profile Print this message


Shawn Stepper

Posts: 96
Joined: 6-Aug-2004

How can I specify a single callback function for multiple buttons? The callback is passed a DBE object, but how can I find out which one was clicked? I tried:

if (passedDBE = globalDBE)

but that was unacceptable.

I tried:

string whichOne = get(passedDBE)

but that didn't work either.

Note: All of the buttons have the same text on them.

I know I could specify a different callback function for each, but that would be pretty ugly.

-------------------------
Shawn Stepper
shawn.e.stepper@wellsfargo.com
Report this to a Moderator Report this to a Moderator
 6-Oct-2004 10:10
User is offline View Users Profile Print this message


Ross Morgan

Posts: 74
Joined: 15-Apr-2004

DBE's don't have retrievable ID's.
is the following too ugly?

int iCB
void CB_generic(DBE x)
{
....
....
if(iCB == 1)
{
....etc
}
}
void CB1(DBE x)
{
iCB = 1
CB_generic(x)
}
void CB2(DBE x)
{
iCB = 2
CB_generic(x)
}
void CB3(DBE x)
{
iCB = 3
CB_generic(x)
}
Report this to a Moderator Report this to a Moderator
 6-Oct-2004 10:44
User is offline View Users Profile Print this message


Dirk Plaschke

Posts: 103
Joined: 17-Sep-2002

Answer Answer
Hi, Shawn.

Use '==' for the condition:

// switchButton.dxl

DB db = null
DBE btn1, btn2, btn3

void cbButtons(DBE dbe)
{
if (dbe == btn1) then print "Button 1 pushed\n"
else if (dbe == btn2) then print "Button 2 pushed\n"
else if (dbe == btn3) then print "Button 3 pushed\n"
}

// main.

db = create("Buttontest")
btn1 = button(db, "Button", cbButtons)
btn2 = button(db, "Button", cbButtons)
btn3 = button(db, "Button", cbButtons)
show(db)

Dirk.

-------------------------
Dirk Plaschke
Report this to a Moderator Report this to a Moderator
 6-Oct-2004 18:50
User is offline View Users Profile Print this message


Shawn Stepper

Posts: 96
Joined: 6-Aug-2004

OK now I feel lame. Must have been the VB scripting I was doing.

-------------------------
Shawn Stepper
shawn.e.stepper@wellsfargo.com
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.