Path: utzoo!attcan!uunet!husc6!purdue!decwrl!asente From: asente@decwrl.dec.com (Paul Asente) Newsgroups: comp.windows.x Subject: Re: accelerators Message-ID: <901@bacchus.dec.com> Date: 14 Nov 88 22:28:40 GMT References: <861@fxgrp.UUCP> Organization: DEC Western Software Lab Lines: 65 In article <861@fxgrp.UUCP> grady@fxgrp (Steven Grady) writes: >This accelerator can be used after it has been installed in >other widgets, using XtInstallAccelerators(). The destination >widget, after this call, will have all the mappings of the >accelerators of the source widget available. Thus, if I >say "XtInstallAccelerators(textEditingWidget, menuWidget)", >then all my accelerators for the menu widget will now be available >from within the context of the text-editing widget. > >Do I have it right so far? So far, so good. >OK, assuming I do.. What does it mean to "display" an accelerator? >Why would a widget want to display its accelerators? >What exactly does the display_accelerator function do? Often times a widget will want to display in itself some representation of the accelerator. For example, if you have a menu item accessible through the ^C accelerator, you might want to display the string "^C" in your menu item. The display_accelerator function gets called when a widget's accelerator is installed, and gets passed a text representation of the accelerator. It can do anything it wants with it, including ignoring it. >There is a variable used by some programs, XtInheritDisplayAccelerator, >which is mentioned in the Xt doc, but not described. >This variable is the only reference to accelerators I've found >in _any_ of the X11 code. Makes it hard to learn by looking >at examples.. Does anyone actually use accelerators? The built-in widgets (Core, Composite...) are basically prototypes; they normally have no actions, and thus, no accelerators. Displaying accelerators is meaningless for them, so they have NULL display_accelerator functions. XtInheritDisplayAccelerator, like other XtInherit values, specifies that a widget should inherit its parent's display_accelerator function. >My other concern is the design of accelerators in general. >My thought is that it would be better to allow have widgets >make public (within the application) those functions that >can be associated with accelerators. Then, any widget which >wants to use an accelerator can bind to that action in a way >similar to other translations, ie: > program*textEditingWidget.translations: #override\ > X: program*menuWidget*itemX() What you specify for the toolkit is program*menuWidget.accelerator: X:itemX() and install the accelerator for menuWidget in some other widget (e.g. textEditingWidget) in your code. >This would allow different widgets to use different accelerators >to access a function -- for instance, one widget could use >"?" to pop up a help widget, whereas another could use >"H". To make an accelerator available to all widgets, >you could simply say: > program*translations: #augment\ > X: program*menuWidget*itemX() One design aim was that a particular widget instance should always have the same accelerator anywhere it is available -- you don't want people to type one accelerator sequence one place and another one someplace else. You may disagree with this, but it seems a laudible goal. -paul asente