[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: newbie question concerning accels
From:       Ellis Whitehead <kde () ellisw ! net>
Date:       2001-11-27 8:33:58
[Download RAW message or body]

Hi Stephan,

On Monday 26 November 2001 02:14 pm, Stephan Stapel wrote:
> Oh, ok. Lets say I have a 3d application that contains viewports like
> 3d viewport, curve editor, shader tree editor, animation mixer, whatever.
> All these viewport provide basic features like zooming, translation
> (scrolling) by using a certain combination of keys (ctrl, alt, shift) and
> mouse keys. Also, most of the viewports allow settings keyframes using a
> certain accelerator and much more actions.
> As all these actions should be available in a homogeneous way, i.e. through
> the same keystrokes in all different viewports, I would like to know how
> other people are doing this in an elegant way. Also, I would need to allow
> changing the keystrokes by the user, for example, someone might not want
> right mouse button + control to translate the viewport but to use mid
> mousebutton for translation.
>
> I was thinking about handing  the keypress and mousepress events to a
> global object which returns the respective action, e.g
> User presses right mouse button + control, event is passed to the global
> 'shortcut evaluator' which checks the key combination against a list of
> actions/key combinations and returns an action token to the viewport
> widget. Is this the most elegant way or are there better ones?
> Comments appreciated :-))=

This sounds like a good approach.  A few thoughts: You'll probably want to 
avoid mixing key and mouse shortcuts in the same class at first for the sake 
of simplicity.  You might try a 'KPointerAccel' (or whatever else) class with:

insertAction( name, i18n(desc), button#, modifier key flags, click/dbl/drag,
	slot object, SLOT(begin), SLOT(move), SLOT(end) );

Example:
ptraccel->insertAction( "translate", i18n(...), 
	KPointerAccel::ButtonRight, Qt::CTRL, KPointerAccel::Drag,
	this, SLOT(slotTranslateBegin(int,int)), SLOT(slotTranslateMove(int,int)),
	SLOT(slotTranslateEnd(int,int)) );
ptraccel->insertAction( "Popup Context Menu", i18n("Popup Context Menu"),
	KPointerAccel::ButtonRight, 0, KPointerAccel::Click,
	this, SLOT(slotPopupContextMenu(int,int)) );

I think your idea could be quite a nice addition to the KDE API if you're 
interested in working it out. ;)

Regards,
Ellis
 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic