Change focus policy in application - Motif
This is a discussion on Change focus policy in application - Motif ; Here is my problem. My application can't catch keyboard events when
there is a VkGenericDialog poped up as a postAndWait if the cursor is
not on this dialog. I'm using the Motif Window Manager with the default
focus policy set ...
-
Change focus policy in application
Here is my problem. My application can't catch keyboard events when
there is a VkGenericDialog poped up as a postAndWait if the cursor is
not on this dialog. I'm using the Motif Window Manager with the default
focus policy set to "Point to type".
I tried XtAddGrab to redirect outside events to my dialog like this :
VkDialogManager::VkDialogReason VkMyGenericDialog:
ostAndWait (
const char *message,
int ok,
int cancel,
int apply,
const char *helpString,
VkSimpleWindow *parent,
Widget parentWidget)
{
createDialog(parentWidget);
XtAddGrab(mBase, True, True);
VkDialogManager:
ostAndWait(message,
ok, cancel, apply, helpString,
parent, parentWidget);
XtRemoveGrab(mBase);
return mDialogReason;
}
Widget VkMyGenericDialog::createDialog(Widget parent)
{
if(mBase) return mBase;
mBase = VkGenericDialog::createDialog(parent);
...
}
I also tried ...
- to set initial focus : XtVaSetValues(mBase, XmNinitialFocus, mMessageFrame, 0);
- to grab focus : _XmGrabTheFocus(mBase, 0);
- to change focus to the dialog's shell :
XmtWarpToShell(GetShell(mBase));
Widget GetShell(Widget widget)
{
if (XtIsShell(widget) || XtParent(widget) == NULL)
{
return widget;
}
return GetShell(XtParent(widget));
}
I also tried to set keyboard focus policy to "Click to type" at the end
of the constructor of my VkApp like this :
XtVaSetValues(GetMainWindowWidget(), XmNkeyboardFocusPolicy,
XmEXPLICIT, 0);
But nothing seems to work. Do you have any advice for me to solve the
problem I have?
Davy
-
Re: Change focus policy in application
Davy Veilleux wrote:
>
> Here is my problem. My application can't catch keyboard events when
> there is a VkGenericDialog poped up as a postAndWait if the cursor is
> not on this dialog. I'm using the Motif Window Manager with the default
> focus policy set to "Point to type".
>
> I tried XtAddGrab to redirect outside events to my dialog like this :
>
> VkDialogManager::VkDialogReason VkMyGenericDialog:
ostAndWait (
> const char *message,
> int ok,
> int cancel,
> int apply,
> const char *helpString,
> VkSimpleWindow *parent,
> Widget parentWidget)
> {
> createDialog(parentWidget);
>
> XtAddGrab(mBase, True, True);
> VkDialogManager:
ostAndWait(message,
> ok, cancel, apply, helpString,
> parent, parentWidget);
> XtRemoveGrab(mBase);
>
> return mDialogReason;
> }
>
> Widget VkMyGenericDialog::createDialog(Widget parent)
> {
> if(mBase) return mBase;
>
> mBase = VkGenericDialog::createDialog(parent);
> ...
> }
>
> I also tried ...
> - to set initial focus : XtVaSetValues(mBase, XmNinitialFocus, mMessageFrame, 0);
> - to grab focus : _XmGrabTheFocus(mBase, 0);
> - to change focus to the dialog's shell :
> XmtWarpToShell(GetShell(mBase));
>
> Widget GetShell(Widget widget)
> {
> if (XtIsShell(widget) || XtParent(widget) == NULL)
> {
> return widget;
> }
> return GetShell(XtParent(widget));
> }
>
> I also tried to set keyboard focus policy to "Click to type" at the end
> of the constructor of my VkApp like this :
>
> XtVaSetValues(GetMainWindowWidget(), XmNkeyboardFocusPolicy,
> XmEXPLICIT, 0);
>
> But nothing seems to work. Do you have any advice for me to solve the
> problem I have?
>
> Davy
The Viewkit postAndWait() function posts the dialog as application
modal. This means that only that dialog can receive events. If you want
other portions of the application to be able to receive events while
this dialog is posted, you must use the post() method instead of
postAndWait().
--
Fred L. Kleinschmidt
Associate Technical Fellow
Boeing Common User Interface Services