T.R | Title | User | Personal Name | Date | Lines |
---|
1423.1 | Where to install accelerators | LEOVAX::TREGGIARI | | Tue Sep 12 1989 12:47 | 11 |
| Accelerators need to be installed on all of the widgets which may take the
input focus. In your test application it is the text widget, not the main
window widget, which takes the input focus. If you change your call to
XtInstallAllAccelerators to:
XtInstallAllAccelerators (tab[k_texte], main_wd);
it will work.
Leo
|
1423.2 | Thank's | BALZAC::CHALUMEAU | | Tue Sep 12 1989 13:29 | 5 |
| Thank you VERY much
Fran�ois
|
1423.3 | But without simple_text ? | BALZAC::CHALUMEAU | | Wed Sep 13 1989 08:39 | 27 |
| Hi,
In my application, I have no simple_text managed in the main window.
The hierarchy is
------------------
I main_window I -> accept_focus = true
------------------
--------------- ----------------
I dialog_box I I menu_bar I
--------------- ----------------
will be a GKS window ----------------
I pulldown_menuI
----------------
----------------
I push_buttons I
----------------
with accelerators
How can I do to take input_focus to the main_window ?
Fran�ois
|
1423.4 | | LEOVAX::TREGGIARI | | Wed Sep 13 1989 09:04 | 19 |
| In that hierarchy, the main window will get input focus, so you should
install the accelerators on the main window. This assumes that the
GKS window DOESN'T take input focus (I don't know if it will...).
You also need to do something with the Dialog box. The server
delivers keyboard events to the focus window BUT to one of its
descendents, IF the pointer is in the descendent AND the descendent
has requested keyboard events. By default, the dialog box does
request keyboard events for handling of the TAB and RETURN keys.
So, you need to either:
o Install the accelerators on the dialog box as well
o Keep the dialog box from requesting keyboard events.
This can be done, but means changing the dialog box's
translation table. I'd recommend the first alternative.
Leo
|
1423.5 | main window doesn't take input focus | BALZAC::CHALUMEAU | | Wed Sep 13 1989 11:02 | 7 |
| I have installed accelerators (by Xtinstallallaccelerators routine)
in the dialog box, but main window doesn't take input_focus.
How can I realease the second way ? or did I forget something
in the first ?
Fran�ois
|
1423.6 | Did you click on the title bar? | LEOVAX::TREGGIARI | | Wed Sep 13 1989 13:02 | 6 |
| The main window window should take focus when you click on the title
bar. That's the only way to get it to take focus without some additional
work on the applications part.
Leo
|
1423.7 | Yes ... | BALZAC::CHALUMEAU | | Wed Sep 13 1989 13:27 | 254 |
| Yes I did ...
This my example without simple_text
(I replaced the GKS window by an Xlib window)
----------------------------------------------------------------
C program
----------------------------------------------------------------
#include <stdio.h>
#include <decw$include:DwtAppl.h>
#define k_boite 0
#define k_b1 1
#define k_b2 2
#define k_b3 3
static DRMHierarchy s_DRMHierarchy;
static char *vec[]={"draw.uid"};
static DRMCode class ;
static void button_activate();
static void create_proc();
static XtEventHandler button_down();
static DRMCount regnum = 2 ;
static DRMRegisterArg regvec[] = {
{"button_activate",(caddr_t)button_activate},
{"create_proc",(caddr_t)create_proc}
};
static Widget toplevel, main_wd, tab[4];
static Display *dis;
static Window win;
static GC gc;
static int x1,x2,y1,y2,count;
/*
* Main program
*/
int main(argc, argv)
unsigned int argc;
char **argv;
{
Arg arglist [2];
DwtInitializeDRM ();
toplevel = XtInitialize("DRAW","class", NULL, 0,&argc, argv);
DwtOpenHierarchy (1,vec,NULL,&s_DRMHierarchy);
DwtRegisterDRMNames (regvec, regnum) ;
DwtFetchWidget (s_DRMHierarchy,"main_wd",toplevel,&main_wd,&class);
XtSetArg (arglist[0], DwtNacceptFocus, TRUE);
XtSetValues (main_wd, arglist, 1);
XtManageChild(main_wd);
XtSetArg (arglist[0], DwtNx, 100);
XtSetArg (arglist[1], DwtNy, 400);
XtSetValues (toplevel, arglist, 2);
XtRealizeWidget(toplevel);
>>>>>>>>>>>>
>>>> XtInstallAllAccelerators (main_wd, main_wd);
>>>> XtInstallAllAccelerators (tab[k_boite], main_wd);
>>>>>>>>>>>>
dis = XtDisplay (tab[k_boite]);
win = XtWindow (tab[k_boite]);
gc = DefaultGC (dis,DefaultScreen(dis));
count=0;
XtAddEventHandler (tab[k_boite], ButtonPressMask, 0, button_down, 0);
XtMainLoop();
}
static void create_proc(widget, tag, list)
Widget widget;
int *tag;
DwtAnyCallbackStruct *list;
{
tab[*tag] = widget;
}
static void button_activate( widget, tag, callback_data )
Widget widget;
int *tag;
DwtAnyCallbackStruct *callback_data;
{
switch ( *tag )
{
case k_b1:
count=0;
break ;
case k_b2:
XClearWindow (dis,win);
count=0;
break ;
case k_b3:
exit(1);
break ;
}
}
static XtEventHandler button_down( widget, data, event )
Widget widget;
int data;
XEvent *event;
{
count += 1;
if (event->xbutton.button == Button1 ) {
if ( count == 1) {
x2 = event->xbutton.x;
y2 = event->xbutton.y;
}
if ( count > 1) {
x1 = x2;
y1 = y2;
x2 = event->xbutton.x;
y2 = event->xbutton.y;
XDrawLine(dis,win,gc,x1,y1,x2,y2);
}
}
}
-------------------------------------------------------------------------
UIL program
-------------------------------------------------------------------------
module exo
version = 'v1.0'
names = case_sensitive
include file 'decw$include:DwtAppl.uil';
procedure
button_activate(integer);
create_proc(integer);
value
accel_1 : compound_string ("^l");
cle_1 : "Ctrl<KeyPress>l:";
accel_2 : compound_string ("^c");
cle_2 : "Ctrl<KeyPress>c:";
accel_3 : compound_string ("^q");
cle_3 : "Ctrl<KeyPress>q:";
k_boite : 0;
k_b1 : 1;
k_b2 : 2;
k_b3 : 3;
object
main_wd : main_window {
arguments {
accept_focus = true;
width = 300;
height = 200;
};
controls {
menu_bar menu;
dialog_box boite;
};
};
object
boite : dialog_box {
arguments {
width = 200;
height = 200;
};
callbacks {
create = procedure create_proc(k_boite);
};
};
object
menu : menu_bar {
arguments {
orientation = DwtOrientationHorizontal;
width = 100;
};
controls {
pulldown_entry fichier;
};
};
object
fichier : pulldown_entry {
arguments {
label_label = "FILE";
};
controls {
pulldown_menu fichier_menu;
};
};
object
fichier_menu : pulldown_menu {
controls {
push_button button_1;
push_button button_2;
push_button button_3;
};
};
object
button_1 : push_button {
arguments {
label_label = 'Lines...';
accelerator_text = accel_1;
button_accelerator = cle_1;
};
callbacks {
activate = procedure button_activate(k_b1);
create = procedure create_proc(k_b1);
};
};
object
button_2 : push_button {
arguments {
label_label = 'Clear';
accelerator_text = accel_2;
button_accelerator = cle_2;
};
callbacks {
activate = procedure button_activate(k_b2);
create = procedure create_proc(k_b2);
};
};
object
button_3 : push_button {
arguments {
label_label = 'Quit';
accelerator_text = accel_3;
button_accelerator = cle_3;
};
callbacks {
activate = procedure button_activate(k_b3);
create = procedure create_proc(k_b3);
};
};
end module;
|
1423.8 | It works for me... | LEOVAX::TREGGIARI | | Wed Sep 13 1989 15:01 | 6 |
| I'm running DECwindows V2 IFT2 (including the DECwindows Window Manager).
But, even if you are running V1, I don't know of anything that got fixed
in this functionality.
Leo
|
1423.9 | what GKS does | POBOX::CHALTAS | Come with me to the Cash Bar | Wed Sep 13 1989 17:54 | 9 |
| If that GKS window is really a window (e.g. you create a WindowWidget,
and pass its window to GKS, worksation type 212) then it won't take
input focus. If, on the other hand, it's a GKS Widget (workstation
type 213 -- you create a Dialog Box and pass its widget ID to GKS) it
*will* take focus whenever a GKS string device is active, and whenever
GKS choice devices 2 or 3 are active.
George
|
1423.10 | It is OK | BALZAC::CHALUMEAU | | Fri Sep 15 1989 11:58 | 4 |
| Thank you very much for your help
Fran�ois
|
1423.11 | MOre accelerator woes | RABBET::FARRELL | Money, there is no substitute! | Wed Jan 31 1990 15:08 | 25 |
|
I have a main window. It has two children, a pop-up dialog box, and a menu
bar.
This dialog box, has another dialog box and and graphic window as children.
I am trying to install accelerators on the pushbuttons of the pulldown menus
of the menu bar.
This works when I XtInstallAllAccelerators on the toplevel widget, but only
when the pointer is over the title bar, or the menu bar of the window.
The largest part of the window, is the graphic window, which doesn't appear
to have the accelerators installed.
If I try to also install the accelerators on the graphics window widget, I
get an access violation and the program dumps.
What do I have to do to get the graphic window to have these accelerators
active?
thanks,
$$$$ ted $$$$
|
1423.12 | one way... | MINNIE::DOUG | just sing it like you feel it | Thu Feb 01 1990 08:21 | 8 |
| this has been in here before. what you have to do is install all
accelerators on all the widgets which might have input focus (in your
app. : main window and dialogue boxes, as i recall).
the way i do this is have the dialog box create proc put a work
procedure in the queue. the work proc then does the
XtInstallAllAccelerators. (pass the dialog box's widget id as the work
procedure's parameter).
|
1423.13 | not only, but also | MINNIE::DOUG | just sing it like you feel it | Thu Feb 01 1990 08:24 | 6 |
| oh, and when you say your main window has a popup dialog box as
child: do you mean statically, or do you really "popup" the popup.
if the popup dialog box is just sitting there inside the main window,
why not use a dialog box instead?
just an extra thought -- dd
|
1423.14 | I know I have to install them, but how? | RABBET::FARRELL | Money, there is no substitute! | Thu Feb 01 1990 13:56 | 10 |
|
RE: .-1 - The dialog box is just a dialog box, not a popup.
RE: .-2 - I tried to install the accelerators on the window, but I received
and access violation. This is what is screwing me up.
The only other valid point I can think of is that I have an EventHandler
installed on this window. Could this be messing me up?
$$$$ ted $$$$
|
1423.15 | | MINNIE::DOUG | just sing it like you feel it | Thu Feb 01 1990 14:55 | 3 |
| did you do the install in the widget creation routine? if so, it's
too early. must do it later, which is why i suggested a work
procedure. --dd
|
1423.16 | A guess | LEOVAX::TREGGIARI | | Tue Feb 06 1990 07:11 | 8 |
| Does your graphic window ever take input focus? If it doesn't you
don't need to install the accelerators on it. If it does, then
here is a wild guess; put at least one translation on the window
widget before installing the accelerators. There have been some
bugs in the Intrinsics when doing things like this to a widget
with a NULL translation table.
Leo
|