Giter VIP home page Giter VIP logo

Comments (4)

alecjacobson avatar alecjacobson commented on July 29, 2024

Thanks for reporting this. Looks like this is our bug, not AntTweakBar's.

Currently the igl::Viewer is setting up glfw with a wrapper to call AntTweakbar's TwKeyPress immediately on "char events" and send all "key events" to AntTweakbar's TwEventKeyGLFW3 (which ignores non-special keys) and then down to the viewer plugins and callbacks. So when you press 't' this fires twice: 1) as a "char event" to TwKeyPress in glfw_char_callback and again 2) as a "key event".

During 1) AntTweakBar finds that we have attached 't' to the "Fill" button and toggles it appropriately. The function correctly returns true revealing that AntTweakBar handled the event, but nobody's listening.

During 2) AntTweakBar ignores 't' since it is not a special key, thus returning false. igl::Viewer thinks this means AntTweakBar has ignored 't' entirely and sends the key down to the plugins and callbacks.

Problem: This will not be trivial to fix. All the plugins and callbacks are set up to implement both key_down and key_up events and not "char events". However, it doesn't seem possible to uncover the "char" from the key events. For example pressing 't' and 'T' (SHIFT + t) is the same "key" but not the same "char". It's not as simple as just checking for shift since this can be keyboard dependent. On my American keyboard SHIFT+'0' is ')' but on a Swiss keyboard it's '='. I don't think we want to implement all keyboard maps...

Proposed solution: Change all plugins and callbacks to include a simple key_pressed event which will fire for non-special keys with the correct casing. Instruct users that this is usually what's needed. Rename the current key_down and key_up events to something like raw_key_down and raw_key_up to discourage general use.

@danielepanozzo The proposed change will likely break many examples and apps. Let's agree when and how to do it and set up some conversion documentation like the last major change in the main library.

To make matters more confusing, it looks like igl::Viewer is implementing its own globally defined TwEventKeyGLFW3. I guess because AntTweakBar's TwEventKeyGLFW uses old key enums? This is an unrelated problem, but I guess we should move this into our, already patched, copy of AntTweakBar in libigl/external/AntTweakBar/. At the very least we ought to clean up all these global functions and global variables.

from libigl.

alecjacobson avatar alecjacobson commented on July 29, 2024

Note: This problem was not solved during the major update to libigl version1.2.

from libigl.

alecjacobson avatar alecjacobson commented on July 29, 2024

Looks like this very same issue is showing up in nanogui, too...

from libigl.

alecjacobson avatar alecjacobson commented on July 29, 2024

This issue has been resolved, see tutorial entry for biharmonic coordinates for proper use of key_pressed (rather than probably-soon-to-be-deprecated key_down). It remains an issue to update all other tutorial entries and to forward this issue to nanogui

from libigl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.