Where to set values for initWithFrame:..... in my NSMatrix subclass
Using Mac OS X.4.11, Xcode 2.5 on PPC In my project I have sub-classed both NSMatrix (e.g FooMatrix) and NSButtonCell (e.g. FooButtonCell). The designated initialiser for FooMatrix is -(id)initWithFrame:(NSRect)frameRect mode:(int)aMode cellClass:(Class)classId numberOfRows:(int)numRows numberOfColumns:(int)numColumns; It is being invoked, I think as side effect of loading the nib (by awakeFromNib maybe?) Since it is a Custom View in IB the values for the parameters cannot be set there. Or at least I don't know how to do it. Yet they do have default values which I speculate come from the Class Object. But I want to set my values such as mode, numberOfRows, numberOfColumns and in particular cellClass. But I am unsure of where to do this. What are my choices and what is the recommended way? (0)Set them in the initialiser, ignoring the parameter values and use the various setXxxYyy methods? (1) What about awakeFromNib? (2) Set them in IB if there is a way? (3) Other possibilities? TIA for your advice and respect. Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Cocoa et al as HCI usability problem
begin rant: Oh me oh my the poor newcomers to Cocoa. Sorry folks back in the days of 360 mainframes there were manuals and they were inscrutable. But if you took the Winston Churchill aproach and spent some blood, sweat, toil and tears you would probably become a 1/2 decent assembler language programmer. Same with Obj- C - if you know C you can grok Obj-C in at most a week - less if you are experienced. You won't be a master of it for a year or so of serious programming. But that's true of acquiring literacy in any field. Finally in this spoon fed age of sound bytes and simplistic and thoughtless political and economic panacea's in a world far more complex that when I grew up (70 years ago) you newbies to Cocoa need to do what the docs provide you with. RTFM! and sweat it out. Or else take the blue pill! Sheesh they all want pay for no work! rant ends: On 18-May-08, at 1:56 PM, Michael Vannorsdel wrote: Well what can you do. Not sure why but lately many newcomers have been showing up and complaining about Cocoa's difficulty. I'm not sure if they've done GUI work before, but I remember my days with PowerPlant and spending a massive amount of time just creating the GUI and the code to back it. Perhaps this is what gave me the sense of how much time Cocoa saves. It's easy to take things like webviews for granted. I can guess the amount of code Apple wrote to back those to work out of the box is pretty massive and complicated. If programming was just drag and drop and clicking some option boxes users could just write their own programs. But the fact is programming is far more complicated than that (and probably will be for a long time) and making such a framework would take a decade or more, by which time it would be obsolete and outdated. For professionals the GUI is a smaller part of development thanks to time saved by Cocoa. If I have to write my own controls from scratch, I will as it's what programmers do, write code. But I'm thankful 99% of the time I can use something from Cocoa that comes with much of the code already done for me. I guess some people are upset Cocoa doesn't do enough, or all, of the work for them. I'm more of the people happy Cocoa does any work for me at all. If it saves me time, it's a good thing. On May 18, 2008, at 10:41 AM, Jens Alfke wrote: "Hobbyists"? I think "professionals" is more accurate — especially since in the early days of the Mac you had to spend hundreds of dollars to become a developer and get access to tools and documentation. I can see your point about obsessive hackers having the stamina to overcome complicated APIs, but any platform vendor's main objective in developer tools is to target professional developers who will create the products that make the platform attractive to customers. "Professional" doesn't necessarily imply a big company; I refer equally to startups and indie outfits, anyone seriously devoted to creating a product. In Apple's defense, the task of implementing a sophisticated GUI on such limited computers was extremely difficult. The top goals were usability, decent performance, and affordable price. That left no leeway for making the APIs themselves easy to use — the niceties we take for granted like object-oriented programming would have used up way too much of that 128k of RAM and 64k of ROM. (Yes, some of the first GUIs were written in the first OOP language, Smalltalk. But the Xerox computers that ran Smalltalk-80 cost $10,000 or more; the ones that ran it with any kind of decent performance (the "Dorado") cost $50,000 and were basically supercomputers. They all had ten times as much RAM as the first Mac, and had custom CPUs with programmable microcode optimized for Smalltalk. Even so, performance was much worse than the original Mac, and the GUI was much cruder and harder to use. I'd already been using Smalltalk-80 when the first Mac came out, and the Mac's speed and aesthetics were just jaw-dropping.) Anyway. I have to say I find this whole discussion frustrating. The attitude of some people seems to be that writing computer programs, of arbitrary complexity, should be as easy as using a word processor. That's a Utopian goal at best, and more generally just naïve. Of course we should be trying to make the APIs and tools and documentation more useable; that's a constant task, and a very difficult one, and one Apple's doing a good job at. (The complexity under the hood is terrifying, and it's already been covered up enough that in an hour an experienced developer can throw together an app that fifteen years ago would have sold for $100.) Face it, any sort of serious creative endeavor is hard! There's no way around it. And the hardest part is learning the techniques and tools. If you wanted to build a robot, play Vivaldi on the violin, design a house, paint landscapes, or cure
Adding a new type of NSButton
Environment is Mac OS X 10.4.11 Xcode 2.5 I need a new type of NSButton/NSButtonCell that I am calling an NSLatchButton. Once it is pushed it stays pushed - pushing it again does not revert it back to unpushed state. (Of course there would be a method to set it to it's unlatched state but pushing the button would not invoke that action) However I'm not sure how to approach this. Should I use categories, extensions, or subclass or what? If I were dealing with the source code I would add to the button types enums and add a method or case to deal with that type. But what suggestions do you have? TIA for your elegant wisdom. respect Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Adding a new type of NSButton
On 25-Jun-08, at 3:22 PM, I. Savant wrote: I need a new type of NSButton/NSButtonCell that I am calling an NSLatchButton. Once it is pushed it stays pushed - pushing it again does not revert it back to unpushed state. (Of course there would be a method to set it to it's unlatched state but pushing the button would not invoke that action) However I'm not sure how to approach this. Should I use categories, extensions, or subclass or what? Why do you need a new button type? No matter how you want it to look, the behavior should be dictated by the controller layer. When its action is fired, simply force its state to be NSOnState. Thanks for that idea - I hadn't thought of it. It's not as clean as I would like but it would work. If I were dealing with the source code I would add to the button types enums and add a method or case to deal with that type. Yes, and I would snarf the freezlehopper until it is within one tenth of a hoptzit of the specified framulator. But that's also unnecessary. ;-) I guess your smile indicates humour. Yes, of course you can subclass NSButton/Cell and add a new type, then override all the drawing routines, etc. to handle that case, but you *still* shouldn't force the button to take on the responsibility of application-specific logic (see "MVC design pattern"). I am familiar with the pattern having used Smalltalk. If I did add a subclass there would be no need to ovveride everything. Only specific set state methods. It's your application's idea that a button can't be "unpushed" once it's pushed; it's your application's responsibility to enforce such a state once set. True which is why I asked for suggestions. But what suggestions do you have? Read the NSButton documentation *and* the target/action mechanism documentation (both easily searchable in Apple's reference library). You're making a mountain out of a mole hill. Perhaps... But for future posts of mine please be so kind as to assume that I've always read the available Apple documentation. I lived by RTFM since 360 Assembler days! In this case the references for NSButton/NSButtonCell plus Button Programming topics. I appreciate your comments. respect... Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Adding a new type of NSButton
On 25-Jun-08, at 3:21 PM, Marco Masser wrote: Once it is pushed it stays pushed - pushing it again does not revert it back to unpushed state. You could simply hook up an appropriate kind of a standard NSButton to an IBAction that disables the button. That way, you can't click it anymore and it stays pushed. If you don't want it to be grayed out upon disabling, you could maybe subclass NSButton and find out which method gets called to draw a disabled button and overwrite that (I never did that and there's probably a more elegant solution for this). Marco Yes it's already hooked up to an action in the Controller. I got this working before posting. But then I started to think about what happens when the button is next pressed. Hence the question. Savants suggestion to set state and then disable in responding to the first click is interesting. Thanks Marco. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Adding a new type of NSButton
On 25-Jun-08, at 4:13 PM, Kevin Elliott wrote: On Jun 25, 2008, at 12:12 PM, P Teeson wrote: Environment is Mac OS X 10.4.11 Xcode 2.5 I need a new type of NSButton/NSButtonCell that I am calling an NSLatchButton. Once it is pushed it stays pushed - pushing it again does not revert it back to unpushed state. (Of course there would be a method to set it to it's unlatched state but pushing the button would not invoke that action) However I'm not sure how to approach this. Should I use categories, extensions, or subclass or what? Is this something are going to use in one place only, or is this something you foresee using in a lot of different places? There are at least two apps where I can use this concept of a Latch. What appealed to me about the NSButton was it maturity as an interface item and I wanted to take advantage of that. I thought making another variant of it was cleaner. If this is something that's a one off control, I'd probably put the logic in the IBAction rather than subclassing. If you need to use this a lot of different places/projects then it's probably worth subclassing. I don't think you can accomplish your goal using categories (wrong tool). OK Thanks In terms of what you need to override that would take some experimentation and thinking. Couple options come to mind- you might try overriding "setState:" and eating any state changes after the first. That was the one that occurred to me. You could also go after the responder chain- possibly in "mouseDown:". That can get a bit messy and I think goes beyond my needs. Other peoples comments about this being a "Controller" problem and not something that belongs in the Model are somewhat true, but if this is really a button type your going to use in several places then subclassing is perfectly appropriate. Also, if it's important to you that the user not get any click behavior (that is, once the button has been "set" then clicking on it again has no visible effect on the control), then I don't think you'll be able to get what you want without subclassing. Yes at present I have code in the Controller. But because I can see uses for it in other apps I plan I raised the idea of adding it as a type by sub-classing. Thanks for your input Kevin. respect Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Adding a new type of NSButton
On 25-Jun-08, at 6:37 PM, Hamish Allan wrote: On Wed, Jun 25, 2008 at 11:01 PM, P Teeson <[EMAIL PROTECTED]> wrote: What appealed to me about the NSButton was it maturity as an interface item and I wanted to take advantage of that. This is a double-edged sword: I for one would find it unsettling if a standard-looking button started behaving differently. If I saw a button stay 'pressed' I'd assume I'd be seeing the spinning beach ball in a few seconds' time. I much prefer the idea of disabling the button after it's pressed. This is becoming fairly standard UI in the HTML/AJAX world (so that servers don't get confused by the same request twice), though I don't much like them for that (because how do I try to repeat the transaction if the network fails?) Good point Hamish. I thought making another variant of it was cleaner. Another visual variant would be much cleaner -- preferably one which mimics the physical characteristics of a real latch. E.g. a horizontal switch like that of Time Machine, with a little catch that falls into the gap once the switch is thrown to prevent it being moved back. Another good point. Using a different image/alternate image could accomplish this. You might also want to ask about this on mac-gui-dev (http://tech.groups.yahoo.com/group/mac-gui-dev/). People there take a great deal of trouble over user interfaces! Hamish Never been to that group. Thanks Hamish ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
NSButton alternate image problem - not redrawing
Mac OS X Tiger 10.4.11, Xcode 2.5, G4 867mhz I am making a Cocoa Application kids game using NSButtons. They are of behaviour Toggle and of type Square Button and the icon position is centred (i.e. no title) and each button has a unique tag and is enabled. The icon images are in the nib file and consist of (a) a coloured blank square and (b) a set of coloured squares with large letters in the centre. In the nib all buttons have the blank icon image as both image and alternate image. Connections are made in IB from each button to the Controller IBAction method. Likewise connections are made from the Controller IBOutlets to the respective buttons. When the game begins I successfully retrieve all the icon images from the bundle and keep them as instance variables in my Controller. (e.g. IBOutlet NSButton * cell0; IBOutlet NSButton *cell1; etc) The game is played by clicking on a button and a message is sent to an IBAction method in the Controller. It replaces the alternate image with one of the (b) icons and disables that button. .. [sender setAlternateImage:theXiconImage]; [sender setEnabled:NO]; .. This all works exactly and desired. There is another NSButton to trigger a New Game and it sends a message to an IBAction method in the Controller that re-initialises the buttons as follows: .. [cell0 setAlternateImage:theBlankImage]; // send messages via IBOutlet [cell0 setEnabled:YES]; [cell1 setAlternateImage:theBlankImage]; [cell1 setEnabled:YES]; [cell2 setAlternateImage:theBlankImage]; [cell2 setEnabled:YES]; etc .. (Of course the Model is also reinitialised) My Problem is this The View gets redrawn OK. But now when clicking on a button there is no guarantee that the alternate images will appear. Sometimes they do; sometimes they don't - just displaying the blank icon. And yet the same action method is being called as in the first play of the game. Why do you think this is not redrawing correctly after the reinitialisation? TIA for your suggestions. ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSButton alternate image problem - not redrawing
On 16-Jul-08, at 1:03 PM, Gary L. Wade wrote: Mac OS X Tiger 10.4.11, Xcode 2.5, G4 867mhz I am making a Cocoa Application kids game using NSButtons. They are of behaviour Toggle and of type Square Button and the icon position is centred (i.e. no title) and each button has a unique tag and is enabled. The icon images are in the nib file and consist of (a) a coloured blank square and (b) a set of coloured squares with large letters in the centre. In the nib all buttons have the blank icon image as both image and alternate image. Connections are made in IB from each button to the Controller IBAction method. Likewise connections are made from the Controller IBOutlets to the respective buttons. When the game begins I successfully retrieve all the icon images from the bundle and keep them as instance variables in my Controller. (e.g. IBOutlet NSButton * cell0; IBOutlet NSButton *cell1; etc) The game is played by clicking on a button and a message is sent to an IBAction method in the Controller. It replaces the alternate image with one of the (b) icons and disables that button. .. [sender setAlternateImage:theXiconImage]; [sender setEnabled:NO]; .. This all works exactly and desired. There is another NSButton to trigger a New Game and it sends a message to an IBAction method in the Controller that re-initialises the buttons as follows: .. [cell0 setAlternateImage:theBlankImage]; // send messages via IBOutlet [cell0 setEnabled:YES]; [cell1 setAlternateImage:theBlankImage]; [cell1 setEnabled:YES]; [cell2 setAlternateImage:theBlankImage]; [cell2 setEnabled:YES]; etc .. (Of course the Model is also reinitialised) My Problem is this The View gets redrawn OK. But now when clicking on a button there is no guarantee that the alternate images will appear. Sometimes they do; sometimes they don't - just displaying the blank icon. And yet the same action method is being called as in the first play of the game. Why do you think this is not redrawing correctly after the reinitialisation? TIA for your suggestions. If I'm reading you right (the action of a button click causes that same button to get a new alternate image), I would say that you should set the alternate image before the user clicks on the button. Once a button is toggled, the current alternate image (or image, depending on state) is drawn Thanks for your thought but I don't see why that is so. Initially the button has blank icons for both images. User clicks on button, action method is called, in that method a different alternate image is set, the button is disabled, the action method is exited, and button is redrawn showing the new image. This all works perfectly for the first play of the game; i.e. when the View is loaded from the .nib. So dynamically changing the alternate image in the action method actually works. However when that game is over the user clicks on the "New Game" button which invokes an action method to restore the game to it's inital values, including the images and enablement of the buttons. (see the above code snippet) Now when the user plays the second, and subsequent, games it's a crap shoot as to whether or not the alternate image actually displays or whether it's just the blank icon that shows up. I don't understand why it wouldn't work as before. Maybe there is some hidden caching going on. respect... Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: NSButton alternate image problem - not redrawing
I posted about this issue but so far only one response. For the full details please see earlier in this thread. This is a summary: Initially the button has blank icons for both image and alternate image. User clicks on button, action method is called, in that method a different alternate image is set by, [sender setAlternateImage:theXiconImage]; then the button is disabled by, [sender setEnabled:NO]; the action method is exited, and button is redrawn showing the new image. However after doing this when the game is over: [cell0 setAlternateImage:theBlankImage]; // send messages via IBOutlet [cell0 setEnabled:YES]; to restore the button to it's original state, clicking on the button is not guaranteed to result in drawing the alternate image as before even though going through same action method. Sometimes it does; sometimes it doesn't -just draws blank image. Why this unexpected behavour? Does this imply no dynamic setting of alternate image? But it works when first loaded from nib. Why not when button state is reset programmatically? I'd appreciate some help on debugging this. Thanks... Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: [SOLVED] NSButton alternate image problem - not redrawing
I solved it - thanks for not replying so I had to find out for myself. Seriously I appreciate it because I read more in Cocoa Drawing Guide and learned quite bit. respect Peter On 17-Jul-08, at 1:19 PM, P Teeson wrote: I posted about this issue but so far only one response. For the full details please see earlier in this thread. This is a summary: Initially the button has blank icons for both image and alternate image. User clicks on button, action method is called, in that method a different alternate image is set by, [sender setAlternateImage:theXiconImage]; then the button is disabled by, [sender setEnabled:NO]; the action method is exited, and button is redrawn showing the new image. However after doing this when the game is over: [cell0 setAlternateImage:theBlankImage]; // send messages via IBOutlet [cell0 setImage:theBlankImage]; // Added this line [cell0 setEnabled:YES]; to restore the button to it's original state, clicking on the button is not guaranteed to result in drawing the alternate image as before even though going through same action method. Sometimes it does; sometimes it doesn't -just draws blank image. Why this unexpected behavour? Does this imply no dynamic setting of alternate image? But it works when first loaded from nib. Why not when button state is reset programmatically? I'd appreciate some help on debugging this. Thanks... Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: [SOLVED] NSButton alternate image problem - not redrawing
But the correct solution is: [cell0 setAlternateImage:theBlankImage]; // send messages via IBOutlet [cell0 setState:NSOffState]; // Added this line [cell0 setEnabled:YES]; Because it's a Toggle button and was in the ON state after being clicked. We can learn something every day if we're not very careful. respect. Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]
Re: Report writer for Cocoa?
On 16-Jan-09, at 11:48 AM, Robert Claeson wrote: On 16 Jan 2009, at 14:09, Jon C. Munson II wrote: I've been a DB developer for many years, albeit on the PC side. Report writing was usually part of the tools, or, something easily found elsewhere in the PC world. Not so easily found on the Mac side though, hence my original question. A good report writer & designer that I can integrate into my own applications is something that I've been missing for years for the Mac. There are such things for the 4G packages that are available for the Mac (Omnis, 4D, FileMaker Pro etc), but nothing for Cocoa apps AFAIK. That's like asking for a report writer for C or C++ and their libraries. Those are languages and frameworks in which you implement applications. Obj-C and Cocoa are a language and a framework. OTOH Omnis, 4D, FileMaker, MySQL, PostgreSQL, Oracle, etc are DB engines with GUI interfaces to help us implement our apps. So it is reasonable to provide tools for report writing in those. Of course for the masochistic one could go back to RPG and mainframes. respect... Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Xcode and Cocoa docs and the Preview sidebar TOC
I recently installed Leopard 10.5.4 and Xcode 3.1.1. Reading the docs launches Preview by default. To see the TOC one opens the sidebar. However I can't get it to open on the lhs of the doc - only the rhs. Yes I tried moving the window to the rhs of the screen and then opening it. Which is the way it works in Mail and in Preview under Tiger. Can't see anything in the Preview prefs for this. So how do I get the Sidebar (a.k.a. Drawer) to open on the lhs of the doc? I did Google and asked in the Leopard forum but no relevant answer so far. (I feel foolish asking this but I havn't yet discovered a way to do it. Yes the coffee has kicked in. I ask in these groups because it's related to their docs.) respect Peter ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to [EMAIL PROTECTED]