[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

3179.0. "Can only use MB2 for popup menu, why ?" by SCOTMN::WOOD (El Vaquero) Wed Aug 08 1990 07:56

  I have an example program to demonstrate the use of popup menu, it
works fine when using MB2 to activate it. When I use MB1,MB3 or
general MB in the translation table specified in UIL, the menu pops up
ok but only MB2 actually highlights and activates the pb entries in the
menu. Why can't I use MB1 or MB3?

See code in next 2 replies.

Cheers for any help

Richard
T.RTitleUserPersonal
Name
DateLines
3179.1POPUP.CSCOTMN::WOODEl VaqueroWed Aug 08 1990 08:01142
#include <decw$include/Dwtwidget.h>
#include <decw$include/DECwDwtApplProg.h>

/* Declare callback procs. */
static XtCallbackProc create_work_window();
static XtCallbackProc create_cb();
static XtCallbackProc end_prog();
static XtCallbackProc activate_pb();

static void show_popup (Widget w,XEvent *event,String *str, Cardinal *count );

static XtActionsRec action[] = {
			{"show_popup",show_popup}
				};

int num_action = (sizeof action / sizeof action[0]);



/* Widgets */

Widget toplevel,
	mainWindow,
	editPopup,
	workWindow;

/* Widget Hierarchy */
DRMHierarchy	hierarchy;

static DRMType *dummyClass,*classPopup;

static char *filenameVector[] = {"popup.uid"};

static int filenameNum = (sizeof filenameVector / sizeof filenameVector[0]);

static DRMRegisterArg reglist[] = {
		{"create_work_window",(caddr_t)create_work_window},
		{"create_cb",(caddr_t)create_cb},
		{"activate_pb",(caddr_t)activate_pb},
		{"end_prog",(caddr_t)end_prog}
				};

static int reglistNum = (sizeof reglist / sizeof reglist [0]);


/* Main Program Begins */

main(argc,argv)
unsigned int argc;
char *argv[];

{
long status;



DwtInitializeDRM();

toplevel = XtInitialize("Top Level",
			"TopLevel",
			NULL,
			0,
			&argc,
			argv);

if (DwtOpenHierarchy(filenameNum,
			filenameVector,
			NULL,
			&hierarchy ) != DRMSuccess)
	printf("\ncan't open hierarchy");

DwtRegisterDRMNames(reglist,reglistNum);

if (DwtFetchWidget (hierarchy,
			"MainWindow",
			toplevel,
			&mainWindow,
			&dummyClass) != DRMSuccess)
	printf("\nCan't fetch Widget from hierarchy");

XtManageChild(mainWindow);

XtAddActions(action,num_action);

XtRealizeWidget(toplevel);

if (DwtFetchWidget(hierarchy,
			"edit_popup",
			workWindow,
			&editPopup,
			&classPopup) != DRMSuccess)
	printf("\nCan't fetch popup");

XtMainLoop();

} /* End Main Prog */

/* Callback and Action routines */

static XtCallbackProc create_cb (widget,tag,reason)
Widget widget;
char *tag;
DwtAnyCallbackStruct *reason;

{
printf("\ncreate callback");
}

static XtCallbackProc create_work_window (widget,tag,reason)
Widget widget;
char *tag;
DwtAnyCallbackStruct *reason;

{
workWindow = widget;
}

static XtCallbackProc end_prog (widget,tag,reason)
Widget widget;
char *tag;
DwtAnyCallbackStruct *reason;

{
exit (1);
}

static XtCallbackProc activate_pb (widget,tag,reason)
Widget widget;
char *tag;
DwtAnyCallbackStruct *reason;

{
printf("\npb = %s",tag);
}

static void show_popup (Widget w,XEvent *event,String *str, Cardinal *count )

{
printf("\nshow popup");
DwtMenuPosition(editPopup, event);
XtManageChild(editPopup);
}
3179.2POPUP.UILSCOTMN::WOODEl VaqueroWed Aug 08 1990 08:03137
module popup
  version = 'v1.0'
  names = case_sensitive

include file 'sys$library:decw$dwtdef.uil';
include file 'decw$include:dwtappl.uil';

procedure
  create_work_window();
  create_cb();
  end_prog();
  activate_pb(string);


value
  file_label	: 'File';
  quit_label	: 'Quit';

object
  MainWindow : main_window {
    arguments { width = 400;
		height = 500;
		 };
      controls {
        menu_bar    main_menu;
	main_window work_window;
      };
	callbacks {
		create = procedure create_cb();
		};
  	};

object
    main_menu : menu_bar {
        arguments { x = 0;
			y = 0;
			height = 30;
			width = 400;
			orientation = DwtOrientationHorizontal;
			spacing     = 15;
			};
        controls {                              
            pulldown_entry file_entry;
        };
    };


object
  file_entry : pulldown_entry {
    arguments { label_label = file_label; 
		};
    controls { pulldown_menu file_menu; };
  };


object
  file_menu : pulldown_menu {
    controls {  push_button  quit_item; };
  };

object
    quit_item : push_button {
        arguments { label_label = quit_label;
             };
        callbacks {
            activate = procedure end_prog ();
            };
        };


list popup_translations : arguments
				{ y = 100;
				width = 400;
				translations = 
					translation_table
					("<BtnDown>: show_popup()");
				};


object
    work_window : main_window {
	arguments { 
			arguments popup_translations;
			};
	callbacks {
		create = procedure create_work_window();
			};
       };

!Popup Menu extentions



object
	edit_popup : popup_menu {
    controls {  
		push_button edit_button;
		push_button delete_button;
		push_button dummy_button; };
  };


object
	edit_button : push_button {
			arguments {
				label_label = "Edit";
				};
			callbacks {
				create = procedure create_cb();
				activate = procedure activate_pb('Edit');
				};
			};

object
	delete_button : push_button {
			arguments {
				label_label = "Delete";
				};
			callbacks {
				create = procedure create_cb();
				activate = procedure activate_pb('Delete');
				};
			};

object
	dummy_button : push_button {
			arguments {
				label_label = "Dummy";
				};
			callbacks {
				create = procedure create_cb();
				activate = procedure activate_pb('Dummy');
				};
			};


end module;
3179.3VMS VersionsSCOTMN::WOODEl VaqueroWed Aug 08 1990 08:041
 Tested under VMS 5.3 and T5.4-4G1
3179.4It's all in the grabRTL::BUTENHOFBetter Living Through Concurrency!Wed Aug 08 1990 08:1116
Because the popup widget assumes that MB2 is used.  It sets up a passive grab on
MB2 within its window when realized.  You can't change it without fiddling with
things you oughtn't to fiddle with�.  XUI popups are designed to work with MB2,
period.

	/dave

�There are ways to fix up the grab.  They're not documented, and they won't work
if the widget changes; say, for example, when you want to migrate to Motif.  I
strongly suggest you don't even try.  If you really want to know, I once wrote
several long notes describing the grab mechanism (primarily to allow realizing
a popup widget dynamically after the button was already down, but it would help
in understanding what's going on in the static case, too).  It's been too long
since I hacked with that stuff to reproduce the information now, and I don't
even know if the notes were in this conference; but then, this sort of hacking
SHOULDN'T be easy!  :-)
3179.5Any documentation on this functionalitySCOTMN::WOODEl VaqueroWed Aug 08 1990 11:0110
  Thanks Dave,  I've come across grabs before (DB - grab_merge_translations),
I had a brief look at the documentation and couldn't find anything that
suggested you couldn't use MB1 or MB3. A customer has submitted an SPR
on this, so I can now explain that his problem is a feature of the PopupMenu
widget design.

Cheers

Richard
3179.6PSW::WINALSKICareful with that VAX, EugeneWed Aug 08 1990 18:445
The XUI Style Guide mandates that MB2 be used for popups.  That is why the
popup widget is designed that way.  The SPR answer is likely to say that this
is an intentional design feature and is not going to be changed.

--PSW
3179.7Send mail for code, if you're not proud :-}UFP::MURPHYA bug? Use the source, Luke!Mon Aug 13 1990 00:138
    If you want an *ugly* *terrrible* *hacky* fix:
    Grab the button. Add an event handler for PointerMotionHints and
    ButtonMotion. In the event handler, set the Button2Mask bit.
    
    Yucch. But it works :-)
    Wait 'til they find out it's impossible to manipulate popup memory,
    even tho it's docmented.
    	-Rick