How to identify calling widget?

I’m calling the same dialog widget (a number pad) from several
different text boxes in my UI and I need to identify which widget is
calling the dialog (so I know where to send the entered number to). How
would I go about doing this? I’ve tried using a startup function for
the dialog, but that just makes the program crash.

thanks,
Meredith

Why don’t you attach a callback to the text boxes and
set a variable that you can read later?

Previously, Meredith Dill wrote in qdn.public.qnx4.devtools:

I’m calling the same dialog widget (a number pad) from several
different text boxes in my UI and I need to identify which widget is
calling the dialog (so I know where to send the entered number to). How
would I go about doing this? I’ve tried using a startup function for
the dialog, but that just makes the program crash.

thanks,
Meredith


Mitchell Schoenbrun --------- maschoen@pobox.com

Meredith Dill <mdill@aseco.com> wrote:

I’m calling the same dialog widget (a number pad) from several
different text boxes in my UI and I need to identify which widget is
calling the dialog (so I know where to send the entered number to). How
would I go about doing this? I’ve tried using a startup function for
the dialog, but that just makes the program crash.

A setup function sounds like the way to go – if it crashes, it means
that you’re probably doing something wrong. It’s hard to tell more
without any details, but believe me, I have used setup functions and
they don’t always crash.

The second argument to a setup function points to an ApInfo_t structure
that contains the pointer to the widget whose callback caused the module
to be opened. Use code similar to the example in the ApName() docs page
to find out which widget it is – or simply compare the pointer with the
appropriate ABW variables.

\

Wojtek Lerch (wojtek@qnx.com) QNX Software Systems Ltd.

Meredith Dill wrote:

I’m calling the same dialog widget (a number pad) from several
different text boxes in my UI and I need to identify which widget is
calling the dialog (so I know where to send the entered number to). How
would I go about doing this? I’ve tried using a startup function for
the dialog, but that just makes the program crash.

thanks,
Meredith

You may better to develop a separate process ( NumPad ). You can find
a good example demo in QNX ftp site ( free ). But its drawback is that
your pad will overlap your text boxes. Thus you can attach a text widget
to the NumPad. When you click a text box in your UI, the NumPad
will be pop up and its text widget’s content is a copy of your text box
( which you can spawn NumPad with parameters — text content
of your text box in your UI and PID of your UI Process ). Typing
in your NumPad will SIMULTANEOUSLY send to the text widget
in your NumPad and text box in your UI. The way is simple:

(1) For the text widget in your NUmPad:

Focus given to that text widget, use PhEventEmit.

(2) For the text box in your UI:

Focus given to your UI process, then use PhEventEmit.

Hope these are helpful to you!

Regards


WeiBing Tong

Aquila Mining Systems Ltd.
1450 City Councillors, Suite 330
Montreal, QC
Canada H3A 2E6
Tel: (514) 874-9917 ext 239
Fax: (514) 874-4005
Email: wbtong@aquilamsl.com

The ApInfo_t sounds like what I want. Does the link_instance argument
point directly to the calling widget, too? I’m trying to call
SetResources on the calling widget.

thanks!
Meredith

Wojtek Lerch wrote:

Meredith Dill <> mdill@aseco.com> > wrote:
I’m calling the same dialog widget (a number pad) from several
different text boxes in my UI and I need to identify which widget is
calling the dialog (so I know where to send the entered number to). How
would I go about doing this? I’ve tried using a startup function for
the dialog, but that just makes the program crash.

A setup function sounds like the way to go – if it crashes, it means
that you’re probably doing something wrong. It’s hard to tell more
without any details, but believe me, I have used setup functions and
they don’t always crash.

The second argument to a setup function points to an ApInfo_t structure
that contains the pointer to the widget whose callback caused the module
to be opened. Use code similar to the example in the ApName() docs page
to find out which widget it is – or simply compare the pointer with the
appropriate ABW variables.


Wojtek Lerch (> wojtek@qnx.com> ) QNX Software Systems Ltd.

Previously, Mitchell Schoenbrun wrote in qdn.public.qnx4.devtools:

Why don’t you attach a callback to the text boxes and
set a variable that you can read later?

This is basically how I do it. I have a function called get_keypad_input() that calls ApCreateModule( ABM_keypad_dlg, … ) and then does this:

// Event loop!
count = PtModalStart();
while (!keypad_done)
{
PtProcessEvent();
}
PtModalEnd(count);


“keypad_done” is a global that gets set by the keypad’s enter key. The number that was entered by the user is stored in another global, which is eventually returned by get_keypad_input().

  • Pete


Previously, Meredith Dill wrote in qdn.public.qnx4.devtools:
I’m calling the same dialog widget (a number pad) from several
different text boxes in my UI and I need to identify which widget is
calling the dialog (so I know where to send the entered number to). How
would I go about doing this? I’ve tried using a startup function for
the dialog, but that just makes the program crash.

thanks,
Meredith

\

Mitchell Schoenbrun --------- > maschoen@pobox.com
\

It works! It turns out that PhAB doesn’t like to have setup functions
in the same file as the class for the new screen. Thanks for all of
your help!

Meredith

Meredith Dill wrote:

I’m calling the same dialog widget (a number pad) from several
different text boxes in my UI and I need to identify which widget is
calling the dialog (so I know where to send the entered number to). How
would I go about doing this? I’ve tried using a startup function for
the dialog, but that just makes the program crash.

thanks,
Meredith