-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose binding #906
Expose binding #906
Conversation
Codecov Report
@@ Coverage Diff @@
## release-candidate #906 +/- ##
=====================================================
- Coverage 44.51% 44.04% -0.48%
=====================================================
Files 337 336 -1
Lines 22477 22430 -47
=====================================================
- Hits 10006 9879 -127
- Misses 12471 12551 +80
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
On second thought, the callback collection could also be on the KeyMappingManager side. With current proposed code, handle event is auto actionPainty = keyMap->getAction( thisKeyMapping::getContext(), buttons, modifiers, key );
auto itr = m_customActions[KeyEventType::KeyPressed].find( actionPainty );
if ( itr != m_customKeyActions[KeyEventType::KeyPressed].end() )
{
itr->second( event );
return true;
} I can try to have setup like void Viewer::setupActionCallbacks() {
auto keyMappingManager = KeyMappingManager::getInstance();
keyMappingManager->setupActionCallback(thisKeyMapping::getContext(), "ACTION_NAME", [this]( QEvent* e ) {
if ( e->eventType() == QEvent::QPress ) { /* key press action */ }
} );
} And handle event could be auto actionTriggered = keyMap->triggerAction( thisKeyMapping::getContext(), buttons, modifiers, key );
if( !actrionTriggered) {
// try another context
} |
I find this second option, with the callback collection on the KeyMappingManager side, quite better. |
In this PR, later |
This PR will closes #793 |
I've done some test ... but it's not as versatile as before. |
Question here, currently keymapping configuration file is stored as a QDomDocument during loading, and updated when one adds new binding, so that when saved, the dom document contains loaded + added actions. |
I guess the question is: do we want to have persistent comments in this file ? In the long term, it would be beneficial to have an UI to edit this file. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not understand how everything work nor if the proposal is the right way to do that but it seems to allow finer customization of the gui event processing system. So, if others approve, I'll do not argue against their decision. I've just a concern on what seems to me to be a strong limitation as custom binding (at least as done in the EntityAnimationDemo, which is the only demo to rely on numeric-key events ) seems to be dependent of the langage (or configuration) of the keyboard.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ready to merge, please update wrt to release_candidate.
Thanks !
[gui] missing include [gui] fix typo Co-authored-by: Mathias Paulin <[email protected]>
remove unused ref (input version only is used)
Adds EventBinding factory, and remove meta enum data member.
bindKeyToAction -> setActionBinding m_mappingAction -> m_bindingToAction
Expose binding
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Expose binding in KeyMappingManager, so client code can inspect and manage binding.
What is the current behavior? (You can also link to an open issue here)
No access to binding.
What is the new behavior (if this is a feature change)?
Nothing changes, this will allow to have better event management, like the one done for custom event in viewer, for all kind of event.
Todo in an upcomming PR: update viewer event handling with something like (example code adapted from WIP ...)
No