[comp.windows.x] Another Resource file question

shipley@riki.berkeley.edu (Pete Shipley) (11/17/89)

I understand how to add new translations to an application though
my resource database.  ie:

#
*VT100.Translations:    #override \
	Ctrl<Key>P:             insert-selection(PRIMARY, CUT_BUFFER0) \n\
	Meta<Key>Y:             insert-selection(PRIMARY, CUT_BUFFER0) \n


Can anyone send a example on how to add accelerator to an application though
the resource database?   For example, with xmh,  I will like to add an
accelerator where I can hit the "n" key and cause the "Next" Command
button to activate and call it's callback.  I know how to install
accelerators from the coding point of view but not from within 
the resource database.




Pete Shipley: 
email: shipley@berkeley.edu		Flames:  cimarron@postgres.berkeley.edu 
       uunet!lurnix!shipley or ucbvax!shipley or pyramid!hippo!{ root peter }
Spelling corections: /dev/null                    Quote: "Anger is an energy"

converse@EXPO.LCS.MIT.EDU (Donna Converse) (11/18/89)

> Can anyone send a example on how to add accelerator to an application though
> the resource database?   For example, with xmh,  I will like to add an
> accelerator where I can hit the "n" key and cause the "Next" Command
> button to activate and call it's callback.

The application has to install your accelerators for you and the 
application has to provide action procedures for you to map to
keyboard accelerators.  The R3 xmh application provides neither.

Suppose the xmh application did install accelerators for you, and
did provide action routines which map to the command functionality
that you are familiar with.  The resource database entry might look
look something like this:

Xmh*someWidgetName.Accelerators: #override\n\
         Meta<Key>space: XmhViewNextMessage()\n\
        :Meta<Key>c:    XmhMarkCopy()\n\
        :Meta<Key>d:    XmhMarkDelete()\n\
        :Meta<Key>f:    XmhForward()\n\
        :Meta<Key>m:    XmhMarkMove()\n\
        :Meta<Key>n:    XmhViewNextMessage()\n\
        :Meta<Key>p:    XmhViewPreviousMessage()\n\
        :Meta<Key>r:    XmhReply()\n\
        :Meta<Key>u:    XmhUnmark()\n


Donna Converse
converse@expo.lcs.mit.edu

asente@decwrl.dec.com (Paul Asente) (11/18/89)

In article <8911171804.AA12209@expo.lcs.mit.edu> converse@EXPO.LCS.MIT.EDU (Donna Converse) writes:
>The resource database entry might look
>look something like this:
>
>Xmh*someWidgetName.Accelerators: #override\n\
>         Meta<Key>space: XmhViewNextMessage()\n\
>        :Meta<Key>c:    XmhMarkCopy()\n\
>        :Meta<Key>d:    XmhMarkDelete()\n\
>        :Meta<Key>f:    XmhForward()\n\
>        :Meta<Key>m:    XmhMarkMove()\n\
>        :Meta<Key>n:    XmhViewNextMessage()\n\
>        :Meta<Key>p:    XmhViewPreviousMessage()\n\
>        :Meta<Key>r:    XmhReply()\n\
>        :Meta<Key>u:    XmhUnmark()\n

Er, no.  The accelerators should be defined upon the widget that exports
the accelerated function, not the one that installs it.  So your database
would look something like

Xmh*nextButton.Accelerators: #override\n\
         Meta<Key>space: Notify()
Xmh*copyButton.Accelerators: #override\n\
        :Meta<Key>c:     Notify()
Xmh*deleteButton.Accelerators: #override\n\
        :Meta<Key>d:     Notify()

and so forth.  There's still the problem that xmh doesn't install
the accelerators for you.

	-paul asente
	    asente@decwrl.dec.com	decwrl!asente

converse@EXPO.LCS.MIT.EDU (Donna Converse) (11/18/89)

> Er, no.  The accelerators should be defined upon the widget that exports
> the accelerated function, not the one that installs it.

Er, yes.  A single widget could export multiple functions, especially
if it is a menu.  But your button example was a better answer to the
question.

Donna Converse
converse@expo.lcs.mit.edu