Git Product home page Git Product logo

Comments (8)

liamHowatt avatar liamHowatt commented on June 16, 2024 1

Ah, I didn't realize that's what you meant. Yes, that works.

from lvgl.

liamHowatt avatar liamHowatt commented on June 16, 2024

Hey @xamix,

I came to the same conclusion about that line in lv_obj.c.

LV_STATE_FOCUS_KEY is the state that themes and styles are are supposed to add an outline for when it's set. POINTERs focus objects the same way ENCODERS and KEYPADS do, except that ENCODERS and KEYPADS set the LV_STATE_FOCUS_KEY state on the object.

This seems to work for getting the outline with a POINTER indev.

static void pointer_click_event_cb(lv_event_t * e)
{
    lv_obj_t * obj = lv_event_get_param(e);
    lv_obj_add_state(obj, LV_STATE_FOCUS_KEY);
}

lv_indev_add_event_cb(pointer_indev, pointer_click_event_cb, LV_EVENT_CLICKED, NULL);

from lvgl.

xamix avatar xamix commented on June 16, 2024

Hi @liamHowatt,

Thank you for your workaround.

However it is not as simple as it since we also need to remove this LV_STATE_FOCUS_KEY on the previous clicked object, otherwise multiple object will have the outline enabled.
Also at start when nothing was already clicked, then nothing is outlined even if something is currenty focused.

Regards.

from lvgl.

kisvegabor avatar kisvegabor commented on June 16, 2024

Hi,

LV_STATE_FOCUS_KEY is added only when a keypad or encoder focused the widget, however LV_STATE_FOCUSED is always added and removed for any kind of focusing. So - if I understand the issue correctly - all you need to do, is using LV_STATE_FOCUSED instead of LV_STATE_FOCUS_KEY.

from lvgl.

liamHowatt avatar liamHowatt commented on June 16, 2024

xamix

we also need to remove this LV_STATE_FOCUS_KEY on the previous clicked object, otherwise multiple object will have the outline enabled.

I am seeing only one set of things outlined at once when I run that snippet. The object(s) being unfocused automatically have that state removed so they aren't outlined anymore.


xamix

Also at start when nothing was already clicked, then nothing is outlined even if something is currenty focused.

Are you basically asking for the outline to be set when anything is focused regardless of the indev?

This does that.

diff --git a/src/core/lv_obj.c b/src/core/lv_obj.c
index 682706ed3..0b1f0453b 100644
--- a/src/core/lv_obj.c
+++ b/src/core/lv_obj.c
@@ -648,8 +648,7 @@ static void lv_obj_event(const lv_obj_class_t * class_p, lv_event_t * e)
         lv_indev_t * indev = lv_indev_active();
         if(indev == NULL) indev = lv_event_get_indev(e);
 
-        lv_indev_type_t indev_type = lv_indev_get_type(indev);
-        if(indev_type == LV_INDEV_TYPE_KEYPAD || indev_type == LV_INDEV_TYPE_ENCODER) state |= LV_STATE_FOCUS_KEY;
+        state |= LV_STATE_FOCUS_KEY;
         if(editing) {
             state |= LV_STATE_EDITED;
             lv_obj_add_state(obj, state);

Maybe we could make this a configurable thing.


kisvegabor

So - if I understand the issue correctly - all you need to do, is using LV_STATE_FOCUSED instead of LV_STATE_FOCUS_KEY.

Setting LV_STATE_FOCUSED in the callback didn't create the outline effect for me.

from lvgl.

kisvegabor avatar kisvegabor commented on June 16, 2024

Setting LV_STATE_FOCUSED in the callback didn't create the outline effect for me.

In lv_theme_default.c I've replaced all LV_STATE_FOCUS_KEYs with LV_STATE_FOCUSED, not created a default group, and I saw the outlines as the widgets ere clicked.

focus

from lvgl.

lvgl-bot avatar lvgl-bot commented on June 16, 2024

We need some feedback on this issue.

Now we mark this as "stale" because there was no activity here for 14 days.

Remove the "stale" label or comment else this will be closed in 7 days.

from lvgl.

lvgl-bot avatar lvgl-bot commented on June 16, 2024

As there was no activity here for a while we close this issue. But don't worry, the conversation is still here and you can get back to it at any time.

So feel free to comment if you have remarks or ideas on this topic.

from lvgl.

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.