shoes / shoes3

a tiny graphical app kit for ruby
http://walkabout.mvmanila.com
Other
181 stars 19 forks source link

setting focus on native widget breaks hide widget behaviour #197

Open passenger94 opened 8 years ago

passenger94 commented 8 years ago

given :

Shoes.app do
    stack do
        flow do
            para "hide"
            check checked: false do |c|
                if c.checked? 
                    @hidden_slot.show
                    @el.focus # bug !
                else
                    @hidden_slot.hide
                end
            end
        end

        @hidden_slot = stack hidden: true do
            @bt = button "nothing"
            @sl = slider
            @el = edit_line ""
            @ck = check
            @rd = radio
            @pg = progress
            @eb = edit_box
            @lb = list_box
        end
    end
end

setting focus on a native widget makes it visible even if setting parent slot to be hidden

Proposed change : (ruby.c https://github.com/Shoes3/shoes3/blob/master/shoes/ruby.c#L3009)

VALUE
shoes_control_focus(VALUE self)
{
  GET_STRUCT(control, self_t);
//  ATTRSET(self_t->attr, hidden, Qtrue); // commenting fix the issue
  if (self_t->ref != NULL) shoes_native_control_focus(self_t->ref);
  return self;
}

this seems to fix the issue, but why the line ATTRSET(self_t->attr, hidden, Qtrue); in the first place ? (why hiding a widget when focusing on it ?, for side effect(s) ?)