[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

3101.0. "odd popup behavior?" by SHALOT::FAILE (Your stairway lies on the whispering wind.) Thu Jul 19 1990 16:54

    I've got a C program & UIL module that creates a main_window widget and
    an associated popup_Menu.  Everything works great except I've noticed
    one thing.  The very first time I press MB2 to get the popup_menu
    displayed I can't select anything from the menu.  If I click again on
    MB2 and have the popup displayed a second time everything works fine
    (and for everytime there after until I exit the application).  Being
    relatively new to DECwindows, I assume that "something" is getting set
    on the first MB2 that allows all the others to work fine.  After
    spending a day in the manuals, any suggestions/pointers would be
    appreciated. ;^)
    
    I've included two test modules (UIL & C) after the form feed in case
    that would help.
    
    Cheers Cody
    
    
module popup_menu

    version = 'v1.0'
    names = case_sensitive

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

value

    k_GOLD_L_button_text		: compound_string("GOLD_L");
    k_GOLD_M_button_text		: compound_string("GOLD_M");
    k_EXIT_SCREEN_button_text		: compound_string("EXIT SCREEN");
    k_NEXT_SCREEN_button_text		: compound_string("NEXT SCREEN");
    k_PREV_SCREEN_button_text		: compound_string("PREV SCREEN");
    k_EXIT_button_text			: compound_string("EXIT");

value

    k_GOLD_L		: 0;
    k_GOLD_M		: 1;
    k_EXIT_SCREEN	: 2;
    k_NEXT_SCREEN	: 3;
    k_PREV_SCREEN	: 4;
    k_EXIT		: 5;

procedure

    mica$decterm_popup(integer);

object
     my_window : main_window
       {
         arguments 
           {
    	     height = 300;
             width = 500;
           };
       };

object
    popup_main : popup_menu 
      {
	controls 
          {
	    push_button GOLD_L_button;
	    push_button GOLD_M_button;
	    push_button EXIT_SCREEN_button;
	    push_button NEXT_SCREEN_button;
	    push_button PREV_SCREEN_button;
            push_button EXIT_button;
	  };
      };

object
    GOLD_L_button: push_button 
      {
	arguments 
          { 
	    label_label = k_GOLD_L_button_text;
	  };
	callbacks 
          { 
	    activate = procedure mica$decterm_popup(k_GOLD_L);
	  };
      };

object
    GOLD_M_button: push_button 
      {
	arguments 
          { 
	    label_label = k_GOLD_M_button_text;
	  };
	callbacks 
          { 
	    activate = procedure mica$decterm_popup(k_GOLD_M);
	  };
      };

object
    EXIT_SCREEN_button: push_button 
      {
	arguments 
          { 
	    label_label = k_EXIT_SCREEN_button_text;
	  };
	callbacks 
          { 
            activate = procedure mica$decterm_popup(k_EXIT_SCREEN);
	  };
      };

object
    NEXT_SCREEN_button: push_button 
      {
	arguments 
          { 
	    label_label = k_NEXT_SCREEN_button_text;
	  };
	callbacks 
          { 
            activate = procedure mica$decterm_popup(k_NEXT_SCREEN);
	  };
      };

object
    PREV_SCREEN_button: push_button 
      {
	arguments 
          { 
	    label_label = k_PREV_SCREEN_button_text;
	  };
	callbacks 
          { 
            activate = procedure mica$decterm_popup(k_PREV_SCREEN);
	  };
      };

object
    EXIT_button: push_button 
      {
	arguments 
          { 
	    label_label = k_EXIT_button_text;
	  };
	callbacks 
          { 
	    activate = procedure mica$decterm_popup(k_EXIT);
	  };
      };

end module;
    
    
    
    
#include <stdio.h>

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

#define	GOLD_L		0
#define GOLD_M		1
#define EXIT_SCREEN	2
#define NEXT_SCREEN	3
#define PREV_SCREEN	4
#define EXIT		5

static DRMHierarchy	s_DRMHierarchy;		/* DRM database hierarch id */
static char		*vec[]={"arch$:[faile.c.decw]popup.uid"};
						/* DRM database file list   */
static DRMCode		class ;

static void mica$decterm_popup();
static void mica$decterm_fetch_popup();
static void mica$decterm_handle_mb2();

static XtActionsRec actions[] = 
        {
          {"mica$decterm_fetch_popup",(XtActionProc)mica$decterm_fetch_popup},
        };

static char popup_translation_table[] =
    	"<Btn2Down>: mica$decterm_fetch_popup()";

static DRMCount		regnum = 1 ;
static DRMRegisterArg	regvec[] = {
    	{"mica$decterm_popup",(caddr_t)mica$decterm_popup}
	};

/*
 *  Main program
 */

int main(argc, argv)
    unsigned int argc;
    char **argv;
{
    /*
     *  Declare the variables to contain the two widget ids
     */

    Widget toplevel, mywindow;
    Arg arglist[1] ;

    /*
     *  Initialize the DRM
     */

    DwtInitializeDRM ();

    /*
     *  Initialize the toolkit.  This call returns the id of the "toplevel"
     *  widget.  The applications "main" widget must be the only child
     *  of this widget.
     */

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

    XtSetArg (arglist[0], XtNallowShellResize, TRUE) ;
    XtSetValues (toplevel, arglist, 1) ;

    /*
     *  Define the DRM hierarchy (only 1 file)
     */

    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");
     }

    /*
     * 	Register our callback routines so that the resource manager can 
     * 	resolve them at widget-creation time.
     */


    DwtRegisterDRMNames (regvec, regnum) ;

    /*
     *  Call DRM to fetch and create the pushbutton and its container
     */

    if (DwtFetchWidget (s_DRMHierarchy,
			"my_window",
			toplevel,
			&mywindow,
			&class)
			!= DRMSuccess)
			    printf("can't fetch interface");

    mica$decterm_handle_mb2(mywindow);

    /*
     *  Make the toplevel widget "manage" the main window (or whatever the
     *  the uil defines as the topmost widget).  This will
     *  cause it to be "realized" when the toplevel widget is "realized"
     */

    XtManageChild(mywindow);
    
    /*
     *  Realize the toplevel widget.  This will cause the entire "managed"
     *  widget hierarchy to be displayed
     */

    XtRealizeWidget(toplevel);

    /*
     *  Loop and process events
     */

    XtMainLoop();

    /* UNREACHABLE */
    return (0);
}

static void mica$decterm_popup( widget, tag, callback_data )
	Widget	widget;
	char    *tag;
	DwtAnyCallbackStruct *callback_data;
{
        unsigned int pop;

        switch (*( (int *) tag) )
          {
            case GOLD_L:
              printf("You Pressed the GOLD_L button\n");
              break;
    	    case GOLD_M:
              printf("You Pressed the GOLD_M button\n");
              break;
            case EXIT_SCREEN:
              printf("You Pressed the EXIT_SCREEN button\n");
              break;
            case NEXT_SCREEN:
              printf("You Pressed the NEXT_SCREEN button\n");
              break;
    	    case PREV_SCREEN:
              printf("You Pressed the PREV_SCREEN button\n");
              break;
            case EXIT:
              printf("You Pressed the EXIT button\n");
              exit(1);
              break;
            default:        
              printf("This should never happen!!!!!\n");
              exit(1);
              break;
          }
}

static void mica$decterm_fetch_popup(w, event, params, num_params)
    	Widget	w;
        XButtonPressedEvent *event;
        char **params;
        int  num_params;
{
  Widget temp;
  if (DwtFetchWidget (s_DRMHierarchy,
			"popup_main",
			w,
			&temp,
			&class)
			!= DRMSuccess)
			    printf("can't fetch interface");

  DwtMenuPosition(temp,event);
  XtManageChild(temp);
}
static void mica$decterm_handle_mb2(w)
    Widget w;
{
    Arg arglist[2];
    XtTranslations parsed_t_table;

    XtAddActions(actions, 1);
    parsed_t_table = XtParseTranslationTable(popup_translation_table);

    XtOverrideTranslations (w, parsed_t_table);
}
T.RTitleUserPersonal
Name
DateLines
3101.1Thats the way it works. Documented?TLE::ROUTLEYKevin Routley - VAX/VMS &amp; XD DEBUGFri Jul 20 1990 11:5247
We had the exact same problem on VAX Debug.

The solution is to fetch the popup menu and associate it with the main window
_before_ the first time the user presses MB2.

In your code, change:

    /*
     *  Realize the toplevel widget.  This will cause the entire "managed"
     *  widget hierarchy to be displayed
     */

    XtRealizeWidget(toplevel);

    /*
     *  Loop and process events
     */

    XtMainLoop();

to:
    /*
     *  Realize the toplevel widget.  This will cause the entire "managed"
     *  widget hierarchy to be displayed
     */

    XtRealizeWidget(toplevel);

    /*  Fetch the popup menu so that the first time the user requests it,
	it will work.  Note that the parent widget must be the main window
        for this to happen.
    */
  if (DwtFetchWidget (s_DRMHierarchy,
			"popup_main",
			mywindow,
			&popup_widget,
			&class)
			!= DRMSuccess)
			    printf("can't fetch interface");

    /*
     *  Loop and process events
     */

    XtMainLoop();

In whatever fashion you deem appropriate.0
3101.2<< Slightly different twist, same result >>BEATLE::COMMO&quot;I&#039;ll find no bug before its time!&quot;Tue Aug 07 1990 13:1139
    I am having similar such problems, although my condiguration is
    different.
    
    The application needs two toplevel window hierarchies that can be iconified
    independantly of each other.  I have my normal "toplevel" shell for the
    "control" window.  For my "graphing" window I created another shell
    using XtCreateApplicationShell.
    
    The popup I am having the problem with is with the second shell.  I
    have tried fetching the popup menu both before and after doing the
    XtRealize on the new shell.
    
    The second shell has the following hierarchy (only the pertinant
    branch is shown)
    
    shell widget (topLevelShellWidgetClass)
        |
    	|
        +----- container widget (main_window widget)
                    |
                    |
                    +------ graphing widget (window widget)
                                    |
                                    |
                                    +----- popup menu (popup_menu widget)
    Event handlers have been installed for pointer motion and leave window 
    notify events as well as the button press event handler that activates 
    the popup.  There is a special cursor (cross hair) active when the 
    pointer is in this graph window.
    
    Same results.  Hitting MB2 brings up the menu (cursor is a cross hair), 
    but no menu highlighting happens until I realise MB2 (the cursor then
    changes to the normal pointer.  Now, pressing wither MB1 or MB2 will
    cause menu selection to occur.  On the second release of the mouse button 
    the menu goes away.
    
    Any hints on where to start looking would be appreciated.
    
    - norm
3101.3<< Answer found... >>BEATLE::COMMO&quot;I&#039;ll find no bug before its time!&quot;Tue Aug 07 1990 13:278
    Cancel the request for info.  After entering the note I realize that
    I hadn't tried one thing and that cause it to work.
    
    Sorry to waster your time.
    
    - norm