Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: How to create a shared event procedure?


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 3 - Last Post: Dec 5, 2014 3:28 AM Last Post By: tim crouse
tim crouse

Posts: 83
Registered: 2/11/02
How to create a shared event procedure?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 4, 2014 4:34 PM
This question stems from my inquiry as how to track which button was pressed on a GUI, "How to determine which button was pressed using an ENUM and a case statement"

Sooooo there were some good answer provided to that question that led me to want to use a shared event assigned to multiple button on-click events. Which would then capture what button was pressed.

I tried the basic approach of selecting one of the buttons on-click event and created the procedure for that buttons event. I then assigned that same procedure to the other buttons. Once I realized what I needed was a common event I was not happy sharing the event based on the name of the original button.

I attempted to edit the procedure name but all button links to that procedure were lost, and the procedure somehow eventually disappeared with all my editing attempts.

Long story short ...

How can I create a procedure for an event (On-Click) that I can assign to multiple buttons on-click events?

Thanks in advance
Tim C.
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: How to create a shared event procedure?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 4, 2014 5:09 PM   in response to: tim crouse in response to: tim crouse
tim wrote:

I attempted to edit the procedure name but all button links to that
procedure were lost

Did you rename the procedure directly in code, or did you rename it using
the Object Inspector? If you rename it directly in code, the event association
will not be updated. If you select the OnClick event in the Object Inspector,
and it is linked to an existing prodedure, typing in a new procedure name
in the OI will rename the existing procedure in the code, and preserve the
event association.

the procedure somehow eventually disappeared with all my editing
attempts.

Was the procedure's body empty when you saved your source file? The IDE
removes an empty event handler from the code and its event association.
The simpliest to avoid that is to type in a comment within the procedure
body.

How can I create a procedure for an event (On-Click) that I can assign
to multiple buttons on-click events?

The simpliest way is to select all of the desired buttons in the Form Designer,
then go to the Object Inspector (which will display only the properties/events
that are common to all of of the selected components), and assign the OnClick
event, which will assign the procedure to all of the selected buttons.

The next simpliest way is to select one button, do the OnClick event creation/assignment,
then go to each of the other buttons and assign their OnClick to the existing
procedure.

--
Remy Lebeau (TeamB)
Remy Lebeau (Te...


Posts: 9,447
Registered: 12/23/01
Re: How to create a shared event procedure?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 4, 2014 5:33 PM   in response to: tim crouse in response to: tim crouse
tim wrote:

I attempted to edit the procedure name but all button links to that
procedure were lost

Did you rename the procedure directly in code, or did you rename it using
the Object Inspector? If you rename it directly in code, the event association
will not be updated. If you select the OnClick event in the Object Inspector,
and it is linked to an existing prodedure, typing in a new procedure name
in the OI will rename the existing procedure in the code, and preserve the
event association.

the procedure somehow eventually disappeared with all my editing
attempts.

Was the procedure's body empty when you saved your source file? The IDE
removes an empty event handler from the code and its event association.
The simpliest to avoid that is to type in a comment within the procedure
body.

How can I create a procedure for an event (On-Click) that I can assign
to multiple buttons on-click events?

The simpliest way is to select all of the desired buttons in the Form Designer,
then go to the Object Inspector (which will display only the properties/events
that are common to all of of the selected components), and assign the OnClick
event, which will assign the procedure to all of the selected buttons.

The next simpliest way is to select one button, do the OnClick event creation/assignment,
then go to each of the other buttons and assign their OnClick to the existing
procedure.

--
Remy Lebeau (TeamB)
tim crouse

Posts: 83
Registered: 2/11/02
Re: How to create a shared event procedure?  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 5, 2014 3:28 AM   in response to: Remy Lebeau (Te... in response to: Remy Lebeau (Te...
Remy Lebeau (TeamB) wrote:

Thank You!

I had no idea about the rename through OI or the multi-select option, very cool stuff.

tim wrote:

I attempted to edit the procedure name but all button links to that
procedure were lost

Did you rename the procedure directly in code, or did you rename it using
the Object Inspector? If you rename it directly in code, the event association
will not be updated. If you select the OnClick event in the Object Inspector,
and it is linked to an existing prodedure, typing in a new procedure name
in the OI will rename the existing procedure in the code, and preserve the
event association.

the procedure somehow eventually disappeared with all my editing
attempts.

Was the procedure's body empty when you saved your source file? The IDE
removes an empty event handler from the code and its event association.
The simpliest to avoid that is to type in a comment within the procedure
body.

How can I create a procedure for an event (On-Click) that I can assign
to multiple buttons on-click events?

The simpliest way is to select all of the desired buttons in the Form Designer,
then go to the Object Inspector (which will display only the properties/events
that are common to all of of the selected components), and assign the OnClick
event, which will assign the procedure to all of the selected buttons.

The next simpliest way is to select one button, do the OnClick event creation/assignment,
then go to each of the other buttons and assign their OnClick to the existing
procedure.

--
Remy Lebeau (TeamB)
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02