home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.windows.x.motif
- Path: sparky!uunet!math.fu-berlin.de!ira.uka.de!scsing.switch.ch!univ-lyon1.fr!ghost.dsi.unimi.it!rpi!news.ans.net!newsgate.watson.ibm.com!yktnews!admin!kendal!dao
- From: dao@rchland.vnet.ibm.com (Dan Dao)
- Subject: New widget and keyboard focus
- Sender: news@rchland.ibm.com
- Message-ID: <1993Jan28.151724.27891@rchland.ibm.com>
- Date: Thu, 28 Jan 1993 15:17:24 GMT
- Reply-To: dao@rchland.vnet.ibm.com
- Disclaimer: This posting represents the poster's views, not necessarily those of IBM
- Nntp-Posting-Host: kendal.rchland.ibm.com
- Organization: IBM Rochester
- Lines: 162
-
-
- --
- I'm writing a new widget and having some problem with keyboard focus.
- What I have inside the new widget are:
-
- 1-foundation (Form widget)
- 2-entry window(Text widget) child of foundation
- 3-scroll window(Scrolled widget) child of foundation
- 4-drawArea (Drawing Area widget) child of scroll window
-
- Here are what I want it to behave:
- 1)When user click on the drawing area, the drawing are should have
- keyboard focus.
- 2)If the draw area has keyboard focus AND user types any key
- except up, down, left and right arrow keys,
- the keyboard focus should transfer to the entry window.
- 3)If the entry window has keyboard focus AND user hits an ENTER
- key, the keyboard focus should transfer to the draw area.
-
- I use XmProcessTraversal to transfer keyboard focus from draw area
- to entry window and it works.
- Yet, when I want to transfer the keyboard focus from entry window to
- draw area, it DOES NOT.
- Why?
- I've noticed in the CoreClassPart structure there's field for
- AcceptFocusProc
- Currently it's being set to NULL. What's this field for anyway?
-
- Thanks
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- Additional info:
- ---------
- Machine: RS6000
- OS: AIX 32
- Motif: 1.1
- Compiler: cc
-
- -----------
- XNewClassRec XnewClassRec =
- {
- {
- /* CoreClassPart */
- (WidgetClass) &widgetClassRec, /* superclass */
- "Command", /* class_name */
- sizeof(XNewRec), /* widget_size */
- NULL, /* class_initialize */
- NULL, /* class_part_initialize */
- FALSE, /* class_inited */
- Initialize, /* initialize */
- NULL, /* initialize_hook */
- Realize, /* realize */
- action_list, /* actions */
- XtNumber( action_list ), /* num_actions */
- cmd_resources, /* resources */
- XtNumber( cmd_resources ), /* num_resources */
- NULLQUARK, /* xrm_class */
- TRUE, /* compress_motion */
- TRUE, /* compress_exposure */
- TRUE, /* compress_enterleave */
- TRUE, /* visible_interest */
- Destroy, /* destroy */
- WindowResize, /* resize */
- Redisplay, /* expose */
- SetValues, /* set_values */
- NULL, /* set_values_hook */
- XtInheritSetValuesAlmost, /* set_values_almost */
- NULL, /* get_values_hook */
- NULL /* accept_focus */
- XtVersion, /* version */
- NULL, /* callback private */
- default_translations, /* tm_table */
- NULL, /* query_geometry */
- NULL, /* display_accelerator */
- NULL, /* extension */
- },
- {
- /*Command Widget ClassPart */
- 0, /* ignore */
- }
- };
-
- -----------
- static void Initialize( XNewWidget request, XNewWidget new )
- {
- ..
- n = 0;
- Foundation = XtCreateManagedWidget( "Foundation", xmFormWidgetClass, XtParent( new ), args, n );
-
- n = 0;
- ..
- EntryWindow = XtCreateManagedWidget( "EntryWindow", xmTextWidgetClass, Foundation, args, n );
- XtAddCallback( EntryWindow, XmNactivateCallback, EnterHit, new );
-
- n = 0;
- ..
- ScrolledWindow = XmCreateScrolledWindow( Foundation, \string{"ScrolledWindow", args, n );
-
- n = 0;
- DrawArea = XtCreateWidget( "DrawArea", xmDrawingAreaWidgetClass, ScrolledWindow, args, n );
- XmAddTabGroup( DrawArea );
-
- XtAddEventHandler( DrawArea, ButtonPressMask, FALSE, ButtonPressed, new );
-
- n = 0;
- XtSetArg( args[n], XmNworkWindow,DrawArea ); ++n;
- XtSetValues( ScrolledWindow, args, n );
-
- XtManageChild( DrawArea );
- XtManageChild( ScrolledWindow );
- }
-
- -----------
- static XtActionsRec action_list[] =
- {
- {"KeyUp", KeyUp},
- {"KeyDown", KeyDown},
- {"KeyLeft", KeyLeft},
- {"KeyRight", KeyRight},
- {"KeyOther", KeyOther},
- };
-
- static char default_translations[] =
- " <Key>osfUp : KeyUp()\n\
- <Key>osfDown : KeyDown()\n\
- <Key>osfLeft : KeyLeft()\n\
- <Key>osfRight : KeyRight()\n\
- <Key> : KeyOther()";
- -------------
-
- static void KeyOther( XNewWidget w, XEvent * event, char * parm[], int i )
- {
- XmProcessTraversal( EntryWindow, XmTRAVERSE_CURRENT );
- }
- -------------
-
- static EnterHit( Widget w, XNewWidget new, XmAnyCallbackStruct * call_data )
- {
- XmProcessTraversal(DrawArea, XmTRAVERSE_CURRENT );
- }
- ---
- Dan Dao dao@rchland.vnet.ibm.com (507)253-8023
-