[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

3484.0. "Using Tabs with Simple Text Widgets in Attached Dialog Boxes" by PEACHS::GILBERT (...You say why, I say I dont know) Wed Oct 17 1990 16:14

The Tab key can usually be used to advance focus from one simple text widget
to the next if they are children of an attached dialog box.  However if I have
a Popup Attached Dialog box controling a Main Window controlling an Attached
Dialog Box controlling the simple text widgets, pressing the tab key does NOT
advance focus to the next simple text widget.  Does anyone know why?

This is what I have tested:

	attached dialog box controls		Tab key works
	    simple text widget

	attached dialog box controls		Tab key works
	    attached dialog box controls
		 simple text widget

	main window controls			Tab key works
	    attatched dialog box controls
		 simple text widget

	attached dialog box controls		Tab key does NOT work
	    main window controls
		attached dialog box controls
		    simple text widget

I have some short c/uil code that demonstrates the above if anyone is 
interested.

Thanks,
Jeff Gilbert
T.RTitleUserPersonal
Name
DateLines
3484.1Dialog and TAB "grabs"LEOVAX::TREGGIARIWed Oct 17 1990 17:5322
By default, dialog boxes (and subclasses) do a server "grab" for the tab
key.  The reason is so that focus can be transfer "synchronously" on the
client side, while the use is typing "asynchronously" on the server side.
When a "grab" activates, the server looks from the root window down for the
highest window which has grabbed for the event, and delivers it to that window.
When the dialog box gets the tab key event, it attempts to give focus to the
next widget.  The problem in your case that doesn't work, 

>	attached dialog box controls		Tab key does NOT work
>	    main window controls
>		attached dialog box controls
>		    simple text widget

is that the process for giving focus to the next widget "breaks down" with the
Main window widget in between the attached dialog box that gets the tab event,
and the widgets that have the focus.

You can work around this by keeping the top attached dialog box from "grab"ing
the tab key.  To do this, set its DwtNgrabKeySyms resource to NULL.  Then, the
tab key will go to the attached dialog box with the text widgets.

Leo
3484.2Does DwtNGrabKeySyms need to be done at creation time?PEACHS::GILBERT...You say why, I say I dont knowThu Oct 18 1990 11:3216
Thanks for the quick response!

I am defining my widgets in UIL. I tried setting grab_key_syms in the arguments
statement of the top level adb, but apparently grab_key_syms is not a defined 
argument in uil.  I then tried getting the widget Id and doing:
	    XtSetArg( arglist[0], DwtNgrabKeySyms, NULL);
	    XtSetValues( TopAdbWidget,arglist,1);
after the adb was created.  

It didn't seem to help.

does this attribute need to be set at creation time?  Is there a way to set
this from uil?

thanks again,
Jeff
3484.3STTEST.C - Here is what I am trying...PEACHS::GILBERT...You say why, I say I dont knowThu Oct 18 1990 14:07178
/*
   Hello World using the DECwindows UIL/DRM Interface
   Modified to test the TAB key with simple text widgets
*/

#include <stdio.h>
#include <decw$include/DECwDwtApplProg.h>

#define windowName        "Hi!"
#define windowClass       "Example"
#define uidFile           "test.uid"
#define mainWidget        "mainWindow"
#define nFiles(x)         (sizeof(x)/sizeof(char *))
#define nRegs(x)          (sizeof(x)/sizeof(DRMRegisterArg))

static void ButtonArmed();        /* arm callback */
static void ButtonActivated();    /* activate callback */
static void DialogBoxCreated();
static void MyOptionCreated();
static void MyItemCreated();
static void DoItActivated();
/*
   Digital Resource Manager (DRM) data structures
*/

static DRMHierarchy hierarchy;      /* DRM database hierarch id */
static char *namvec[] = {uidFile};  /* DRM database file list */
static DRMCode class;
static DRMRegisterArg regvec[] = {
          {"ButtonArmed",     (caddr_t)ButtonArmed},
          {"ButtonActivated", (caddr_t)ButtonActivated},
          {"DialogBoxCreated",(caddr_t)DialogBoxCreated},
	  {"MyOptionCreated", (caddr_t)MyOptionCreated},
	  {"MyItemCreated",   (caddr_t)MyItemCreated},
	  {"DoItActivated",   (caddr_t)DoItActivated},
       };

Widget top_level,        /* top level widget */
       main_widget,      /* application main widget */
       dialog_box,
       MyOptionMenu,
       MyFirstItem;
	  
Display *display;

main(argc,argv)
   unsigned int argc;
   char *argv[];
{
   int status,n;
   Arg arg;



   /* Initialize the Digital Resource Manager */

   DwtInitializeDRM();

   /* Initialize the toolkit, and create the top-level widget */

   top_level = XtInitialize(windowName,       /* application name */
                            windowClass,      /* application class */
                            NULL,             /* pointer to options */
                            0,                /* number of options */
                            &argc,argv);      /* command line */

   /* Define the DRM hierarchy */

   status = DwtOpenHierarchy(nFiles(namvec), /* number of files */
                             namvec,         /* file names */
                             NULL,           /* no extensions */
                             &hierarchy);    /* pointer to hierarchy id */

   if (status != DRMSuccess) {
      fprintf(stderr,"Can't open DRM hierarchy\n");
      exit(0);
   }

   /* Register callback routines */

   DwtRegisterDRMNames(regvec,nRegs(regvec));

   /* Ask DRM to create the pushbutton widget */

   status = DwtFetchWidget(hierarchy,    /* DRM hierarchy id */
                           mainWidget,   /* index of widget to fetch */
                           top_level,    /* parent widget */
                           &main_widget, /* returned widget id */
                           &class);      /* returned widget class */

   if (status != DRMSuccess) {
      fprintf(stderr,"Can't fetch widget\n");
      exit(0);
   }

   /* Include fetched widget in its parent's managed set */

   XtManageChild(main_widget);

   /* Realize the widget heirarchy, creating and mapping windows */

   XtRealizeWidget(top_level);

   display = XtDisplay(top_level);

   XtInstallAllAccelerators(dialog_box,dialog_box);

   /* Wait for something to happen */

   XtMainLoop();  /* Never returns */
}

static void ButtonArmed(widget,tag,reason)
   Widget widget;
   char *tag;
   DwtAnyCallbackStruct *reason;
{
   Arg arg;
   int Version,Revision,Release;
   XtSetArg(arg,DwtNlabel,DwtLatin1String(tag));
   XtSetValues(widget,&arg,1);
   Version = XProtocolVersion(display);
   Revision = XProtocolRevision(display);
   Release = XVendorRelease(display);
   printf("Version:%d  Revision:%d  Release:%d\n",Version,Revision,Release);


}

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


static void DoItActivated(widget,tag,reason)
   Widget widget;
   char *tag;
   DwtAnyCallbackStruct *reason;
{
   Arg al[1];
   printf("Saw the Do It button pressed.\n");
   XtSetArg(al[0], DwtNmenuHistory, MyFirstItem);
   XtSetValues(MyOptionMenu, al, 1);
}


static void DialogBoxCreated(widget,tag,reason)
   Widget widget;
   char *tag;
   DwtAnyCallbackStruct *reason;
{
   dialog_box = widget;
   printf("Got the dialog box widget Id.\n");
}

static void MyOptionCreated(widget,tag,reason)
   Widget widget;
   char *tag;
   DwtAnyCallbackStruct *reason;
{
   MyOptionMenu = widget;
   printf("Got the Option Menu widget Id.\n");
}

static void MyItemCreated(widget,tag,reason)
   Widget widget;
   char *tag;
   DwtAnyCallbackStruct *reason;
{
   MyFirstItem = widget;
   printf("Got the widget Id of the first menu item.\n");
}


3484.4STTEST.UILPEACHS::GILBERT...You say why, I say I dont knowThu Oct 18 1990 14:10229
!++
!  COPYRIGHT (c) 1988 BY
!  DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASSACHUSETTS.
!  ALL RIGHTS RESERVED.
! 
!  THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
!  ONLY  IN  ACCORDANCE  OF  THE  TERMS  OF  SUCH  LICENSE  AND WITH THE
!  INCLUSION OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR  ANY  OTHER
!  COPIES THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY
!  OTHER PERSON.  NO TITLE TO AND  OWNERSHIP OF THE  SOFTWARE IS  HEREBY
!  TRANSFERRED.
! 
!  THE INFORMATION IN THIS SOFTWARE IS  SUBJECT TO CHANGE WITHOUT NOTICE
!  AND  SHOULD  NOT  BE  CONSTRUED  AS A COMMITMENT BY DIGITAL EQUIPMENT
!  CORPORATION.
! 
!  DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE  OR  RELIABILITY OF ITS
!  SOFTWARE ON EQUIPMENT WHICH IS NOT SUPPLIED BY DIGITAL.
!--

module helloworld
    version = 'v1.0'
    names = case_sensitive
include file 'DECW$INCLUDE:DwtAppl.uil';

value
    jg_grab_key_syms: argument('DwtNgrabKeySyms',integer);

procedure
    helloworld_button_activate();
    get_mw_id();

!object helloworld_main : popup_attached_db
object helloworld_main : attached_dialog_box
       {
       arguments {
!	  jg_grab_key_syms = 0;
       };
       controls
         {
             main_window  helloworld_mw;
         };
       callbacks 
	 { 
	    create = procedure get_mw_id();
         };       
       };

object helloworld_mw: main_window {
!object helloworld_main: main_window {
	  arguments {
	  width = 200;
	  height = 200;
	  };
         controls
	  {
	     menu_bar  helloworld_menubar;
	     attached_dialog_box helloworld_adb;
	  };

      };

object  helloworld_menubar: menu_bar {
	    arguments {
	    x=0;
	    y=0;
	    };
	    controls  {
			pulldown_entry controlmenuentry;
	    };	
	};

object	controlmenuentry: pulldown_entry {
	    arguments {
			label_label = compound_string('Control');
	    };
	    controls {
			pulldown_menu controlmenu;
	    };		
	};

object  controlmenu: pulldown_menu {
	    controls {
			push_button helloworld_button;
	    };
	};

object
    helloworld_button : push_button {
	arguments { 
	    label_label = 'Hello\nWorld!';
	};
	callbacks { 
	    activate = procedure helloworld_button_activate();
	};
    };


object helloworld_adb: attached_dialog_box {
	controls {
		   simple_text stw1;
		   simple_text stw2;
		   simple_text stw3;
		   simple_text stw4;
		   simple_text stw5;
		   simple_text stw6;
		};
	};

object stw1: simple_text {
	arguments {
		adb_top_attachment = DwtAttachAdb;
		adb_left_attachment = DwtAttachAdb;
		rows = 1;
		cols = 5;
		width = 20;
		blink_rate = 0;
		max_length = 5;
		editable = true;
		simple_text_value = 'one   ';
		pending_delete = true;
	};
	};


object stw2: simple_text {
	arguments {
		adb_top_attachment = DwtAttachAdb;
		adb_left_attachment = DwtAttachWidget;
		adb_left_widget = simple_text stw1;
		rows = 1;
		cols = 5;
		width = 20;
		blink_rate = 0;
		max_length = 5;
		editable = true;
		simple_text_value = 'two   ';
		pending_delete = true;
	};
	};


object stw3: simple_text {
	arguments {
		adb_top_attachment = DwtAttachAdb;
		adb_left_attachment = DwtAttachWidget;
		adb_left_widget = simple_text stw2;
		rows = 1;
		cols = 5;
		width = 20;
		blink_rate = 0;
		max_length = 5;
		editable = true;
		simple_text_value = 'three ';
		pending_delete = true;
	};
	};


object stw4: simple_text {
	arguments {
		adb_top_attachment = DwtAttachWidget;
		adb_top_widget = simple_text stw1;
		adb_left_attachment = DwtAttachAdb;
		rows = 1;
		cols = 5;
		width = 20;
		blink_rate = 0;
		max_length = 5;
		editable = true;
		simple_text_value = 'four  ';
		pending_delete = true;
	};
	};


object stw5: simple_text {
	arguments {
		adb_top_attachment = DwtAttachWidget;
		adb_top_widget = simple_text stw2;
		adb_left_attachment = DwtAttachWidget;
		adb_left_widget = simple_text stw4;
		rows = 1;
		cols = 5;
		width = 20;
		blink_rate = 0;
		max_length = 5;
		editable = true;
		simple_text_value = 'five  ';
		pending_delete = true;
	};
	};


object stw6: simple_text {
	arguments {
		adb_top_attachment = DwtAttachWidget;
		adb_top_widget = simple_text stw3;
		adb_left_attachment = DwtAttachWidget;
		adb_left_widget = simple_text stw5;
		rows = 1;
		cols = 5;
		width = 20;
		blink_rate = 0;
		max_length = 5;
		editable = true;
		simple_text_value = 'six   ';
		pending_delete = true;
	};
	};


!object
!	controls {
!	    label	helloworld_label;
!	    push_button	helloworld_button;
!	};
!   };


object
    helloworld_label : label {
	arguments {
	    label_label =
		'Press button once\nto change label;\ntwice to exit.';
	};
    };

end module;
3484.5Must be set at creation timeLEOVAX::TREGGIARIThu Oct 18 1990 15:0017
> does this attribute need to be set at creation time?

Yes.

> Is there a way to set this from uil?


Yes.  You need to use a user-defined argument.  Exactly what
to specify has been entered into this or one of the other
DECwindows notes file before, I don't remember.  But try

( ARGUMENTS
    { ARGUMENT ( 'grabKeySyms', INTEGER ) = 0;
     };
};

Leo
3484.6Still no go...PEACHS::GILBERT...You say why, I say I dont knowMon Oct 22 1990 00:559
                    <<< Note 3484.5 by LEOVAX::TREGGIARI >>>
                       -< Must be set at creation time >-

I think I tried basicly what you describe, (see -.2 or -.3) and it I 
still get the same results.  I also tried setting the attribute after 
creation of the widget but as you said, that wouldn't work anyway.

Thanks for your help,
Jeff
3484.7It works now.PEACHS::GILBERT...You say why, I say I dont knowTue Oct 23 1990 15:068
re -.1

...or I thought I tried what you said.  I spelled it DwtGrabKeySyms instead of
grabKeySyms.  I changed it and now it works like a charm.

Thanks again for your help.

Jeff
3484.8'grabKeySyms' and not 'DwtNgrabKeySyms'ALEXWS::ALEXBugs are coming in triplets ...Thu Oct 25 1990 10:5620
	Jeff,

	I've seen in your .UIL file that you incorrectly defined the grabKeySyms
by:
       jg_grab_key_syms : argument ('DwtNgrabKeySyms', INTEGER);

	The argument name DOES NOT contain "DwtN" prefix. I think that this will
help you

	Cheers,
		Alex

P.S.
	BTW the apropriate way to define grabKeySyms is by INTEGER_TABLE. I've
did that a while ago and it worked allowing one to set two different keys to
for moving focus among SText children of dialog box.

		Alex