[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

2768.0. "Help on grabKeySyms in dialog box widget" by ALEXWS::ALEX (Bugs are coming in triplets ...) Wed May 16 1990 06:29

	Hi there!

	Can anyone, provide me with a working example of setting Return key
instead of/in addition to Tab key as focus moving mechanizm in dialog boxes.

	I've tried to modify grabKeySyms and grabMergeTranslations, but it does
not work for me yet. One of the problems is that UIL (V1) does not recognize
grabKeySyms as a built-in argument and there is no way to specify
"null-terminated list of KeySyms".

	I'm adding my code (C and UIL) to this request.

	Thanks in advance,
		Alex

/* dialog.c */
#include <stdio.h>

#include <decw$include/DwtAppl.h>       /* DECwindows Toolkit */
#include <decw$include/KeySym.h>	/* KeySym definitions */

static KeySym  grab[] = { XK_Tab, XK_Return, 0 };

static DRMHierarchy	s_DRMHierarchy;		/* DRM database hierarch id */
static char		*vec[]={"dialog.uid"};
static DRMCode		class ;

static void quit();
static void create_dialog();

static DRMRegisterArg	regvec[] = {
	{"CreateDialog",(caddr_t)create_dialog},
	{"Quit",	(caddr_t)quit}
	};
static DRMCount		regnum = (sizeof(regvec)/sizeof(regvec[0]));

/*
 *  Main program
 */
int main(argc, argv)
    unsigned int argc;
    char **argv;
{
    Widget toplevel, main;
    Arg arglist[1] ;


    DwtInitializeDRM ();
    toplevel = XtInitialize(
    "Dialog",			/* application name */
    "Dialog",			/* application class */
    NULL, 0,                        /* options */
    &argc, argv);                   /* command line parameters */

    if (DwtOpenHierarchy (1,			    /* number of files	    */
			  vec,			    /* files		    */
			  NULL,			    /* os_ext_list (null)   */
			  &s_DRMHierarchy)	    /* ptr to returned id   */
			  != DRMSuccess)
	  { printf ("can't open hierarchy"); }

    DwtRegisterDRMNames (regvec, regnum) ;

    if (DwtFetchWidget (s_DRMHierarchy,
		"MainWindow",
		toplevel,
		&main,
		&class)
			!= DRMSuccess)
	  { printf("can't fetch interface"); }

    /*
     * Ask Main window for it's placement and set toplevel
     */
    {
    Arg al[3];
    short int x,y;

	XtSetArg(al[0], DwtNx, &x);
	XtSetArg(al[1], DwtNy, &y);
	XtGetValues(main, al, 2);

	XtSetArg(al[0], DwtNx, x);
	XtSetArg(al[1], DwtNy, y);
	XtSetArg(al[2], XtNallowShellResize, TRUE) ;
	XtSetValues(toplevel, al, 3);
    }

    XtManageChild(main);
    XtRealizeWidget(toplevel);

    XtMainLoop();

}

static void quit( widget, tag, callback_data )
	Widget	widget;
	char    *tag;
	DwtAnyCallbackStruct *callback_data;
{
    exit(1);
}


static void create_dialog( widget, tag, callback_data )
	Widget	widget;
	char    *tag;
	DwtAnyCallbackStruct *callback_data;
{
    Arg	al[1];

    XtSetArg(al[0], DwtNgrabKeySyms, grab);
    XtSetValues(widget, al, 1);

}


module dialog
    names = case_sensitive
    objects = {
    label = gadget;
    push_button = gadget;
    separator = gadget;
    toggle_button = gadget;
    }

!++
!
! Facility:
!   Test
!
! Abstract:
!   Check translations to add Return key as move focus
!
! Author:
!   Alexander Katz
!
! Creation Date:
!   13-MAY-1990
!
! Modification History:
!   [-tbs-]
!
!--

    include file 'decw$include:DwtAppl.uil';

    procedure

	Quit;
	CreateDialog;

    value
    gt : private translation_table (
    '~Shift<Key>Return:	DWTDIMOVEFOCUSNEXT()',
    ' Shift<Key>Return:	DWTDIMOVEFOCUSPREV()');

    object

	MainWindow : private main_window
	    {
	         arguments {
		     x = 400;
		     y = 100;
		     width = 250;
		     height = 100;
		};
		  controls {
		    menu_bar	MenuBar;
		    dialog_box Dialog;
		  };
	      };


      MenuBar : private menu_bar
	{
	    controls {
	    	 push_button QuitButton;
	    };
      };

      QuitButton : private push_button
        {
	    arguments {
		label_label = 'Quit';
	    };
	    callbacks {
		activate = procedure Quit;
	     };
      };


      Dialog : private dialog_box
	{
	    arguments {
		grab_merge_translations = gt;
	    };
	    controls {
		 label		Label1;
		 simple_text	SText1;
		 label		Label2;
		 simple_text	SText2;
	    };
	    callbacks {
		create = procedure CreateDialog;
	    };
     };


    Label1 : private label
	{
	    arguments {
		x = 0;
		y = 0;
		label_label = "First Field";
	    };
    };

    SText1 : private simple_text
	{
	    arguments {
		x = 50;
		y = 0;
		cols = 16;
		rows = 1;
		resize_height = false;
		resize_width  = false;
		max_length = 16;
		auto_show_insertion_point = true;
	    };
    };

    Label2 : private label
	{
	 arguments {
	    x = 0;
	    y = 25;
	    label_label = "Second Field";
	 };
     };

     SText2 : private simple_text
	{
	    arguments {
		x = 50;
		y = 25;
		cols = 16;
		rows = 1;
		resize_height = false;
		resize_width  = false;
		max_length = 16;
		auto_show_insertion_point = true;
	      };
      };

end module /* dialog */;


T.RTitleUserPersonal
Name
DateLines