jverzani / gWidgets2

Rewrite of gWidgets
35 stars 9 forks source link

`font(gbutton_obj)` fails to return font information #66

Closed landroni closed 10 years ago

landroni commented 10 years ago

Consider the following:

w <- gwindow("Buttons", visible=T)
g <- ggroup(cont=w, horizontal=FALSE)
b1 <- gbutton("open", cont=g)
font(b1) <- list(weight = "bold")

Now from ?font I would expect that:

> print(font(b1))
NULL

would return the font information (e.g. list(weight = "bold")), but instead all it returns is NULL. Is this a bug?

jverzani commented 10 years ago

I don't have a get_font method implemented. I'd suggest wrapping your font code in something like this:

setFont = function(obj, spec) {
font(obj) <- spec
tag(obj, "font") <- spec
}
getFont = function(obj) tag(obj, "font")

You could make it fancier if you wished.

landroni commented 10 years ago

Thanks for the tip. I ended up implementing something similar.

But I was wondering if a get_font method would still be warranted in this case?

jverzani commented 10 years ago

The problem is that implementing it is not so easy, as far as I know. I don't think the underlying toolkits make it so simple. I'd be happy to be proven wrong.