colinta / teacup

This project has been sunset in favor of MotionKit
github.com/motion-kit/motion-kit
Other
604 stars 85 forks source link

can I access variable from the controller within the stylesheet ? #117

Closed michaelcinquin closed 10 years ago

michaelcinquin commented 11 years ago

Hi

if I do in the controller :

myTextField=NSTextField.new myTextField.title="some long text" myTextField.sizeToFit

@myView=subview(NSView, :myView) do @myTextField=subview(myTextField, :styleTextField) end

In the stylesheet, is it possible to get @myTextField.frame.size.height, so as to be able to set the height of :myView ?

I want to use subviews to work with Constraints.

Hope the question makes sense and you can look into it

colinta commented 10 years ago

Sorry I never got back to you!

Stylesheets and controllers cannot share data the way you're attempting here; you'll need to apply styles, or set different style names, from your controller.

colinta commented 10 years ago

That said, using constraints you should be able to refer to the text field height; it will calculate the best height similarly to how you are calling sizeToFit