thomthom / SKUI

Ruby wrapper of classes that maps to GUI controls in SketchUp's UI::WebDialogs
MIT License
26 stars 14 forks source link

Textbox.font not working? #106

Open mogensen-co opened 7 years ago

mogensen-co commented 7 years ago

It seems font is not having any effect for Textbox, but works for other controls

text = SKUI::Textbox.new( 'Some text')
text.font = SKUI::Font.new( 'Segoe UI', 12 )  

or ... am I missing something !?

thomthom commented 7 years ago

hm.. I am able to reproduce. It should be that Textbox need to set some extra explicit style to have the font propagate to the input element. input elements are notorious in terms of styling, but setting the font should be possible. I'm guessing that whatever the Base class is doing doesn't apply to input elements.

I also noticed that on my retina machine the text sizes were not right.

mogensen-co commented 7 years ago

Thanks Thomas, that gave me a clue ... Form elements (input, select, textarea, button) does NOT inherit font property, though I have no clue to the deeper logic of this. It seems it can be fixed by adding a font-family on the body, and then adding { font-family:inherit; } on the control's CSS (input, select, textarea, button) I will try it out later.

thomthom commented 7 years ago

In one of the examples it shows that buttons do change, but maybe that's because I used a <button> element instead of <input> element. I'm not sure, I didn't dig too far into this right now. I'm currently out and about travelling.

mogensen-co commented 7 years ago

Hmm .. No - you did use an input element on SKUI::Textbox I took a shot in the dark and added this to the CSS file:

.control-textbox input, .control-textbox textarea
{ 
  font:inherit;
}

And then it works :) ... No need to specify a font-family anywhere. It could be that it is also needed elsewhere - but button seems to working fine without!?!

mogensen-co commented 7 years ago

Ahh ... For SKUI::Button <button> is not wrapped in a <div>,so that works fine without. Thomas, if there are other controls that are wrapped inside a <div>,they also need the font:inherit;

thomthom commented 7 years ago

hm... I don't recall. It's been a while since I worked on SKUI. If you have a fix that solves your issue I can accept it as a Pull Request and merge it.