davidl@hammer.GWD.TEK.COM (David Leslie) (03/30/89)
I am having a problem with the toolkit which baffles me. I'm using Athena widgets plus the Menu widget from the contrib directory in the R3 distribution, running X11R3 on a Tektronix 4319. I have an application which puts up a vpane window containing several text windows among other things. I'm overriding the translation for Btn2Down to pop up a menu inside these text windows. Even though the Menu widget expects to bind to a command widget, it works fine with a text widget. These are read-only text widgets, so I don't care about losing the capability of dumping a selection into them. (I've modified the Menu widget to bind MenuPopup to Btn2Down instead of ButtonDown). What I'd like to be able to do is to pop up one of two menus, depending on where the pointer is when the Btn2Down event occurs, in two of these text windows. Thus I have a routine called Btn2Proc which is bound to Btn2Down for these two text widgets, which checks the x co-ordinate when the button down event occurs, and tries to pop up one menu if x is greater than a certain value, another menu if it's less. I'm doing this by binding Btn4Down to MenuPopup(menu1) and Btn5Down to MenuPopup(menu2), then in Btn2Proc, copying the incoming event into a local XButtonEvent structure, changing the button field to either 4 or 5, and then calling XtDispatchEvent with the new event, to popup the desired menu. So far so good, all of this works fine. However, when the menu pops up, events are not being dispatched to the menu's command widgets. I'd like enter/leave events to set/unset the command buttons, as should happen with the Menu widgets, but no go. When I release button2 I get a 'leave' event sent to the underlying command widget as the menu pops down, but otherwise nothing. I should mention that in my other text windows, where I have bound Btn2Down directly to MenuPopup(menuX), all works fine. Enter/leave events are propagated to underlying command widgets, and Btn2Up selects correctly. The problem seems to lie with use of XtDispatchEvent to generate the popping-up event, rather than popping up with a 'real' event. Here is an example of tranlations that produce the flawed behavior I've described: static String trans_table_1 = " <Btn2Down>: btn2_proc(source1W) \n\ <Btn4Down>: MenuPopup(Menu1) \n\ <Btn5Down>: MenuPopup(Menu2)"; Binding <Btn2Down> directly to MenuPopup(menuX) works fine, as does something like <Btn2Down>: any_function() MenuPopup(menuX) My questions are: 1. Is there a better way to do this? I thought about somehow associating an InputOnly window with, say, the left section of the text widget, and handling events for this window to popup menu1, with menu2 coming up for the rest of the text window. The mechanics of mixing windows and widgets in this way seemed too formidable. 2. Why are events not being sent to child command widgets for my menus popped up with XtDispatchEvent? What am I doing wrong? Any help from toolkit gurus is greatly appreciated. Dave Leslie Interactive Technologies Division Tektronix, Inc. Wilsonville, OR davidl@orca.WV.TEK.COM (503) 685-2541