Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 26, 2013, 09:13 PM   #1
Blakeasd
macrumors 6502a
 
Join Date: Dec 2009
Expression is not Assignable

Hello,

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:

Code:
 [_window setTitleBarHeight:60.0]; //1
    
    NSView *titleBarView = self.window.titleBarView; //2

    newTitleView.bounds.size.width = titleBarView.bounds.size.width; //3
    
    
    [titleBarView addSubview:newTitleView]; //4
The newTitleView is an IBOutlet in Interface Builder (a view with the textfield in it), and the _window is just my standard INAppStoreWindow. The view has the textfield perfectly aligned in it and displays fine in the window's titlebar. The issue is resizing. The textfield won't resize when the window resizes. I though that to fix this I should make the newTitleView change in width with the titleBarView, so I added line 3 above. I get an error though when I try to run it, stating: "The Expression is not assignable." So how can I make it "Assignable". And if I do succeed, will the textfield resize?

Thanks!
Blakeasd is offline   0 Reply With Quote
Old Jan 26, 2013, 09:40 PM   #2
ArtOfWarfare
macrumors 603
 
ArtOfWarfare's Avatar
 
Join Date: Nov 2007
Send a message via Skype™ to ArtOfWarfare
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:

http://stackoverflow.com/questions/9...16702#14116702

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:

Code:
[newTitleView setBounds:[titleBarView getBounds].size.width];
Except that doesn't work, because setBounds: expects a CGRect, not a CGFloat.

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.
ArtOfWarfare is offline   0 Reply With Quote
Old Jan 26, 2013, 10:29 PM   #3
ytk
macrumors regular
 
Join Date: Jul 2010
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.
ytk is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
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

Forum Jump

All times are GMT -5. The time now is 03:28 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC