|Jan 26, 2013, 09:13 PM||#1|
Expression is not Assignable
I am working on a window that is a subclass of the INAppStoreWindow. I am attempting to add an NSTextField to the window, which I have done, but there are some "fine tuning" issues. The INAppStoreWindow is a window that lets you get its "titlebarview" and add stuff to it. I have added a textfield to it like this:
[_window setTitleBarHeight:60.0]; //1 NSView *titleBarView = self.window.titleBarView; //2 newTitleView.bounds.size.width = titleBarView.bounds.size.width; //3 [titleBarView addSubview:newTitleView]; //4
|Jan 26, 2013, 09:40 PM||#2|
This was answered on StackOverflow over here... I provided what, in my opinion, was a pretty good solution for how you can do what you want:
The answer why this isn't possible is because when you type out newTitleView.bounds on the left side of an assignment, it compiles to this:
[newTitleView setBounds:[titleBarView getBounds].size.width];
Something you may or may not realize is this: bounds is a property of views, but size is a member of struct CGRect and width is a member of struct CGSize... size and width are not properties. If you don't understand that, you might be in need of refreshing yourself on C structs.
Don't tell me Macs don't last: 2007 iMac, 2007 Mac Mini, 2008 MacBook Air, all Vintage.
(iMac obsoletion: April 28, 2015, MBA: October 14, 2015, Mac Mini: March 9, 2016)
Last edited by ArtOfWarfare; Jan 26, 2013 at 09:45 PM.
|Jan 26, 2013, 10:29 PM||#3|
I'm going to offer you my totally half-assed, uninformed, all-but-worthless answer here, and say that in Cocoa the only appropriate way to set the size of the bounds of an NSView is with the view's setBounds: or setBoundsSize: methods. I don't think there's any way to set only the width directly, but since an NSSize is just a struct containing two floats, you should be able to build the struct on the fly by combining titleBarView.bounds.size.width and newTitleView.bounds.size.height, and then pass the resultant struct to [newTitleView setBoundsSize:]. I'm drawing a blank on the exact syntax for doing this in Objective-C at the moment, but I'm pretty sure it's possible.
Of course, I could be completely wrong, and you should probably disregard everything I've written here.
|Thread Tools||Search this Thread|
|thread||Thread Starter||Forum||Replies||Last Post|
|Regular expression / sed question.||Big Dave||Mac Programming||9||Feb 26, 2014 11:51 PM|
|AE Expression to tie image brightness to 3d light intensity value||Policar||Digital Video||0||Jan 7, 2013 11:39 AM|
|Resolved: Onkyo HDMI Assignable Port||Macman45||Digital Audio||0||Jul 24, 2012 12:23 AM|
All times are GMT -5. The time now is 01:23 PM.