Re: Cross XIB references?
• Subject: Re: Cross XIB references? • User-agent: Microsoft-Entourage/12.23.0.091001 On Sat, 05 Jun 2010 22:14:22 +0100, Jean-Fran?ois Brouillet em...@hidden said: So ... is there a way to refer to NIB1.objA from NIB2.objB ? This is probably the most FAQ in the entire Cocoa universe, so check the archives. But basically it's up to YOU to organize things so that there's a chain of references that connects the instances you need connected. Thanks Matt, but first I *did* Google left and right to no avail (but yes I have to admit that I didn't Bing :-), and judging by your answer it looks like you are talking about something I didn't ask. I am *NOT* querying about how to create some object graph *programatically*, but how it is possible, if at all, to control drag from one object's outlet in nib#1 to some other target in nib#2 USING INTERFACE BUILDER. Obviously IB does support some (so far as I have experienced: limited) form of cross nib references in the Attributes Inspector, but I haven't been able to make references to my singleton in NIB#1 from anywhere in NIB#2. Please, prove me wrong and point me to that FAQ :-)___ 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
Re: Cross XIB references?
On Jun 6, 2010, at 2:19 AM, Jean-François Brouillet wrote: • Subject: Re: Cross XIB references? • User-agent: Microsoft-Entourage/12.23.0.091001 On Sat, 05 Jun 2010 22:14:22 +0100, Jean-Fran?ois Brouillet em...@hidden said: So ... is there a way to refer to NIB1.objA from NIB2.objB ? This is probably the most FAQ in the entire Cocoa universe, so check the archives. But basically it's up to YOU to organize things so that there's a chain of references that connects the instances you need connected. Thanks Matt, but first I *did* Google left and right to no avail (but yes I have to admit that I didn't Bing :-), and judging by your answer it looks like you are talking about something I didn't ask. I am *NOT* querying about how to create some object graph *programatically*, but how it is possible, if at all, to control drag from one object's outlet in nib#1 to some other target in nib#2 USING INTERFACE BUILDER. Obviously IB does support some (so far as I have experienced: limited) form of cross nib references in the Attributes Inspector, but I haven't been able to make references to my singleton in NIB#1 from anywhere in NIB#2. The point is that the only connections between the objects in any NIB and the rest of an application's object graph are through the placeholder/proxy objects like File's Owner and Application. So, asking how to connect an object in one NIB to another is the same as asking how to connect it to anything else in your app. You go through those placeholder/proxy objects and their properties. For example, in most real-world cases, your NIB should not contain your model. Most NIBs other than MainMenu.nib don't even contain a coordinating controller (as opposed to mediating controllers). And yet your View (in the MVC sense) does have a connection to the Controller and does, ultimately, reflect the state of the model. So, how is that accomplished? The answer is the same: through those placeholders and their properties. To put it another way: you probably already know how to do what you seek, because you've already done it. Not all of the connections you've established have been between objects in your NIB. Some have been from objects in your NIB to objects outside of your NIB (File's Owner and Application). You're asking about a special case of the same basic technique. In short: no, you can't Control-drag from objects in one NIB to objects (or placeholders) in another. If you think you need to, you're incorrect. (I'd also point out that it would make no sense to do so. A NIB may be loaded multiple times. It does not represent a single object graph. It represents a template of an object graph that can be reproduced at will. So, what would such a cross-NIB connection actually mean? Which objects would be connected to which other objects?) Regards, Ken ___ 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
Re: Cross XIB references?
I can see that my question may not be very clear, so I'm taking another angle :) A few years ago when Spring came out in Java land, I had an Aha moment when I realised that it was just about creating singletons all over the place (Spring calls them beans) without the benefit of a nifty editor, and remember saying to myself, Gosh, here we go again, competition is catching up with Apple with a 10 years delay. They've just reinvented NIB files Despite this monstrosity called XML, Spring files *have to* be edited by hand, but you can refer to anything in either that Spring file OR some other Spring file, whether that second Spring file is loaded later or earlier than the first. You do NOT have the benefits of an editor, but cross Spring file references are a given. Back to NIB (err ... XIB) files, I had a cursory look at the XML and thought to myself: Well, they must call it progress, but here's an instance where Apple has been corrupted by the outside and this format is inscrutable, clearly not meant for human consumption, despite what the XML zealots claim as human readable. Thankfully, we've got a top notch editor (IB of course) that knows how to untangle this mess, and making reference to object id 123 in file one.xib to object id 456 in file two.xib should be a walk in the park ... Well, it looks like I'm in for some disappointment here. Yes, there is some form of cross XIB references supported by IB (via the Attribute Inspector) but as far as setting up a cross reference from any top level (aka: singleton) object to any other object (top level or not) in some other nib file, it looks like either IB does NOT support it, or, I was not able to discover the magic gesture that would enable me to do so. To be pristinely clear, I am *NOT* asking how I could programatically implement awakeFromNib and perform the magic myself at runtime, but I am asking whether cross NIB file references have a generic, builtin support, the same way as, in Spring land, they defer instantiation until after they have been able to construct the whole graph in memory: There I do *not* have to write Java code to perform the wiring, and I would expect the same in IB/ObjC/NIB land. Is that possible and how? Many thanks -- JFB ___ 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
Re: Cocoa: dragging files from Finder
Yes, you were both right. Once I moved registerForDraggedTypes to awakeFromNib method everything runs as it should. Thanks a lot, Marcin ___ 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
Re: Cross XIB references?
Le 6 juin 2010 à 09:12, Jean-François Brouillet a écrit : A few years ago when Spring came out in Java land, I had an Aha moment when I realised that it was just about creating singletons all over the place (Spring calls them beans) without the benefit of a nifty editor, and remember saying to myself, Gosh, here we go again, competition is catching up with Apple with a 10 years delay. They've just reinvented NIB files NIB (or XIB) files are not singletons, or do I misinterpret what you are trying to say? Joanna -- Joanna Carter Carter Consulting ___ 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
Re: Cross XIB references?
On Jun 6, 2010, at 3:12 AM, Jean-François Brouillet wrote: [...] making reference to object id 123 in file one.xib to object id 456 in file two.xib should be a walk in the park ... You're still not getting it. There are no such objects. NIBs are object graph templates, not object graphs. If two.xib is loaded twice, to which object id 456 does object id 123 have a connection? Well, it looks like I'm in for some disappointment here. Yes, there is some form of cross XIB references supported by IB (via the Attribute Inspector) but as far as setting up a cross reference from any top level (aka: singleton) object to any other object (top level or not) in some other nib file, it looks like either IB does NOT support it, or, I was not able to discover the magic gesture that would enable me to do so. You keep referring to singleton in a way which makes no sense to me. Singleton's have nothing to do with NIBs, as far as I see. In fact, it's pretty difficult to imagine how a singleton could be contained in a NIB. To be pristinely clear, I am *NOT* asking how I could programatically implement awakeFromNib and perform the magic myself at runtime I may have missed them, but I didn't see suggestions that you approach it this way. I suggested, and I saw others suggest, that you connect to File's Owner or Application or bind to or through those. Doing so can be done completely within IB, although the properties of classes do have to be coded. Regards, Ken ___ 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
Re: [iPhone] Preprocessing events sent to UITableView
On Jun 6, 2010, at 2:09 AM, glenn andreas wrote: On Saturday, June 05, 2010, at 05:51PM, WT jrca...@gmail.com wrote: I need to hijack the set of touch events sent to a UITableView instance prior to allowing the table to process those events. I have a custom UIView, of which the table view is a subview, and I override -hitTest:withEvent: there (in the custom view) to return self, thereby preventing the table from receiving those touches. Since my custom view does not implement any of the four event-handling methods (-touchesBegan:withEvent:, etc), the view controller managing my custom view gets the touches, through the regular traversal of the responder chain. There, in the view controller event-handling methods, I determine whether or not I need to consume the events. If not, I need to send them back to the table view for it to do its normal event handling (for instance, scrolling). All of the above works fine, except... Probably not as fine as you expect - UIViews are not designed to support UIEvents forwarded to them except under very controlled conditions. From http://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/EventHandling/EventHandling.html#//apple_ref/doc/uid/TP40007072-CH9-SW17: The classes of the UIKit framework are not designed to receive touches that are not bound to them; in programmatic terms, this means that the view property of the UITouch object must hold a reference to the framework object in order for the touch to be handled. If you want to conditionally forward touches to other responders in your application, all of these responders should be instances of your own subclasses of UIView. That document contains a number of suggestions on how to approach those sort of design issues... Yes, I'm aware of that recommendation. I think that's precisely the core of my question, namely, how to do what I need to do in the safest possible way. I found a solution, but I don't think it's very elegant: I subclassed UITableView and, in that subclass, I implement the 4 event methods to call their namesakes in the tableview's superview. Since that superview doesn't implement those methods (it's a regular UIView, not a custom view), its view controller gets the calls (through the normal traversal of the responder chain). There I do the analysis to decide whether or not to consume the touches. If not, then I call fake event methods in the tableview's subclass, each of which invokes the super version of the true event methods. It works like a charm, but it's not very elegant, in my opinion.___ 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
Re: Cross XIB references?
On 6 Jun 2010, at 09:38, Ken Thomases wrote: On Jun 6, 2010, at 3:12 AM, Jean-François Brouillet wrote: [...] making reference to object id 123 in file one.xib to object id 456 in file two.xib should be a walk in the park ... You're still not getting it. There are no such objects. NIBs are object graph templates, not object graphs. If two.xib is loaded twice, to which object id 456 does object id 123 have a connection? In the same exact way that spring files are object graph *templates* and not object graphs. It would be more effective to just answer No. What you say you want is not supported rather than missing the point. I gave a very concrete use case of my singleton thing. I have ONE (=singleton) UINavigationController that contains one navigationItem that contains one titleView. This controller is my root controller I want and need exactly ONE such controller. In my XIB file I then create one of those UIViewImage proxy object (yes, just a template) and in that template I say: BTW the image (UIImage, another proxy/template) I want is: xyz.png. I then connect my titleView to that proxy. Done. End of story. Next. Just works. No awakeFromNib magic or what not. Now in *another* nib file I have *another* controller and I wanted to tell it: BTW the image you want is in nib file 1, object id 789 The consensus here seems to be that this is not possible, but please, stop telling me that it doesn't make sense. So, I've got the message, thank you, and I'm going to *programatically* share that view either in the app delegate or the root view controller, whichever way is cleanest. But hint to Apple whoever maintains NSBundle the IB connexion: I may not be the only one missing the generalised support of cross file references the way the otherwise grossly inferior Spring does it. Well, it looks like I'm in for some disappointment here. Yes, there is some form of cross XIB references supported by IB (via the Attribute Inspector) but as far as setting up a cross reference from any top level (aka: singleton) object to any other object (top level or not) in some other nib file, it looks like either IB does NOT support it, or, I was not able to discover the magic gesture that would enable me to do so. You keep referring to singleton in a way which makes no sense to me. Singleton's have nothing to do with NIBs, as far as I see. In fact, it's pretty difficult to imagine how a singleton could be contained in a NIB. My mistake. I shouldn't have used the word singleton. What I mean is distinguished instance. Many Thanks -- JFB___ 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
Re: Cross XIB references?
On Jun 6, 2010, at 4:34 AM, Jean-François Brouillet wrote: It would be more effective to just answer No. What you say you want is not supported rather than missing the point. I did say that. I also tried to give you the conceptual grounding so that you could understand why. This controller is my root controller I want and need exactly ONE such controller. In my XIB file I then create one of those UIViewImage proxy object (yes, just a template) and in that template I say: BTW the image (UIImage, another proxy/template) I want is: xyz.png. I then connect my titleView to that proxy. You are misunderstanding my use of the word proxy. You are incorrectly combining it with my use of the word template. I did not mean to suggest that each thing in a NIB is a proxy (or a template). The NIB as a whole is a template for an object graph. Most of the things in a NIB are freeze-dried objects that get reconstituted each time the NIB is loaded. _Some_ things in a NIB, though, are not freeze-dried objects. They are placeholders in the object graph. When a NIB is loaded, an owner object is passed in to the loading machinery. That pre-existing object is plugged into the new object graph in the hole represented by File's Owner in the NIB. Also, the application object is plugged into the hole represented by Application in the NIB. Neither the application object nor the owner object are in the NIB. Only proxies / stand-ins / placeholders are there in the NIB editing process to allow you to establish connections and bindings to those objects even though they aren't in the NIB. My point is that your view controller is not in the NIB. It should be what loads the NIB, thus it has to pre-exist the NIB. It passes itself in as the owner of the NIB, thus allowing for the new object graph created by loading the NIB to be connected to the pre-existing object graph of the application. Any connection from the objects in the NIB to any other objects must be formed by such connections to the File's Owner or Application placeholders, or by bindings to/through their properties. Now in *another* nib file I have *another* controller Again, does the second NIB _contain_ the other controller or merely reference it via its File's Owner placeholder? Generally speaking, it should just reference it. and I wanted to tell it: BTW the image you want is in nib file 1, object id 789 That doesn't designate a unique object. A NIB may be loaded multiple times during the lifetime of an application. Each time, a different set of objects is created. In order for the designation to be specific to a single object, you'd have to say nib file 1, object id 789, for NIB load 7 (or whatever). Even that doesn't really work, since the NIB-loading machinery doesn't give you direct access to the full object graph. If you were to get into the details of the NIB-loading classes, you'd see they can return an array of the top-level objects from the NIB, but not any deeper objects. The correct way to get at a specific object within the NIB is to declare an outlet on the File's Owner class and connect that to the object. (In theory, you could try to traverse the object graph from the top-level objects, but you have very little to go on to find any specific object. The names and IDs that you see in IB are not meaningful anywhere else and are not available to you in the loaded object graph.) What you have said also smacks of using the View layer as though it were Model state. If the UIImage is indeed part of the model, it shouldn't reside in the NIB. It should reside in your model layer and your views would obtain it from their controller. If the UIImage is itself not a part of the model, then perhaps the particular image name being used is. In that case, each NIB would have a separate UIImage, but each might bind its image name to a property of the controller. The consensus here seems to be that this is not possible, but please, stop telling me that it doesn't make sense. Except it doesn't make sense. Given what NIBs are -- that is, given my point about how a (NIB file name, object ID) pair doesn't uniquely designate an object -- there is no conceivable way to implement cross-NIB connections. If that differs from Spring or whatever, then so be it. NIBs aren't those. So, I've got the message, thank you, and I'm going to *programatically* share that view either in the app delegate or the root view controller, whichever way is cleanest. You shouldn't be sharing views. For one thing, a view can only be part of one view hierarchy at a time. I think that attempting to share views is going to cause you no end of grief. Multiple views may reflect shared model state, though. Regards, Ken ___ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the
Re: Cross XIB references?
Am 05.06.2010 um 23:14 schrieb Jean-François Brouillet: Consider the situation where I have a root ImageView in IB. I specify the actual image I want it to hold by just filling/ selecting which of the existing images are already present in the project, using the Image input box of the Image View Attributes inspector. Then I can just set the titleView outlet of some navigationItem elsewhere in the same nib file, and voilà, my image is displayed at runtime exactly where I want I, when I want it. But now I create a second nib file for a second controller, and I really would like to display the same image in the same kind of setup. Problem is: I haven't figured out whether it is possible at all for nib file#2 to refer to any object inside nib file#1, No it is not. hence I have to either pay the memory cost of a duplicate object in the second nib file, Yes. as Ken told you, views can have only one superview. So, I've got the message, thank you, and I'm going to *programatically* share that view either in the app delegate or the root view controller, whichever way is cleanest. This will break. See above. And because you will try it you make clear that you did not understand the answer given by Ken. or forget about nib files entirely and do the whole wiring by hand with code, which kind of defeats the purpose of separate nib files in the first place. Why should you have to do that? You just need one titleView in every nib. A simple imageView takes up some bytes in memory. The image itself is shared anyway. You win nothing by trying to reuse that view. So ... is there a way to refer to NIB1.objA from NIB2.objB ? No. And there never will be, as it is impossible (see Ken’s very good explanation). It _is_ a beginners question and it was answered in detail. Bonus question: is it possible at all to refer to nib files (while staying within IB) outside of the main project directory? I tried variations on ./rsrc/mynib2 or rsrc/mynib2 in the NIB Name input field to no avail ... They have to be anywhere in the project. Just use the name, as they will be copied to Resources. I plainly understand that I can spread my NIB files all over the place (almost :-) if I go the coding route, but I'd rather do everything I can in IB if that's possible ... Yes, use nibs. Then just add that one image view and be done with it. atze ___ 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
Re: Cross XIB references?
This has been dealt with at length, as far as I can tell, but going back to your original post, here's my threepenn'orth... On 06/06/2010, at 7:14 AM, Jean-François Brouillet wrote: Hi. Consider the situation where I have a root ImageView in IB. I specify the actual image I want it to hold by just filling/ selecting which of the existing images are already present in the project, using the Image input box of the Image View Attributes inspector. This works because [NSImage imageNamed:blah] is able to search a variety of locations it knows about to try and locate the image file by name. It does not work by referencing objects across nibs. Then I can just set the titleView outlet of some navigationItem elsewhere in the same nib file, and voilà, my image is displayed at runtime exactly where I want I, when I want it. But now I create a second nib file for a second controller, and I really would like to display the same image in the same kind of setup. You can do that - just specify the same image name in the IB inspector. Because of the way images can be loaded by name from resources, this works, and shares the image instance so loaded. Problem is: I haven't figured out whether it is possible at all for nib file#2 to refer to any object inside nib file#1, No, you can't. hence I have to either pay the memory cost of a duplicate object in the second nib file, The cost is absolutely minute and not worth sweating. The image (as loaded, in memory and possibly cached as a bitmap) might have some considerable cost which would be worth not duplicating across instances of that image. Luckily, NSImage does that for you pretty much by default. Avoiding the duplication of an image VIEW on the other hand, is simply not worth the trouble. The code needed to avoid duplicating the instance, even if it could be made to work without bugs (unlikely) would swamp the saving you'd gain. or forget about nib files entirely and do the whole wiring by hand with code, which kind of defeats the purpose of separate nib files in the first place. Not really. The purpose of separate NIB files is not to avoid duplicating instances of lightweight interface objects. So ... is there a way to refer to NIB1.objA from NIB2.objB ? No, with the exception of known shared objects such as the NSApplication instance or its delegate. It's also possible to add shared singleton objects to a NIB file in some cases but it's a slightly more advanced use which isn't the same as what you think you mean by singleton. (e.g. Sparkle's main object is a singleton and is typically added to the MainMenu NIB file). Bonus question: is it possible at all to refer to nib files (while staying within IB) outside of the main project directory? I tried variations on ./rsrc/mynib2 or rsrc/mynib2 in the NIB Name input field to no avail ... No. I plainly understand that I can spread my NIB files all over the place (almost :-) if I go the coding route, but I'd rather do everything I can in IB if that's possible ... Just pull your interface objects together as you want them in each nib and forget about trying to share them across NIBs or different instances of the window in your app. It's pointless, premature optimisation and unsupported anyway. Object IDs and names within IB are not visible to your code. The name is an aid for you to identify an object, I guess the ID might have some similar purpose but as far as I can tell it's an IB internal implementation detail and I'm not sure why it's even exposed to the user. General advice would be to stick to conventional approaches until you know the stuff so intimately that clever shortcuts could be worth considering, but then only if they can be proven to have some real benefit. What you're attempting is not only unconventional (which is why it seems difficult - a big clue there) but you have not shown that it would have any benefit whatsoever. It might be tempting to prematurely optimise in this way but resist it - it's the sure path to disappointment. Sharing image instances is sensible, which is why NSImage already does that for you. --Graham ___ 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
Re: Cross XIB references?
On Sun, 06 Jun 2010 08:19:06 +0100, Jean-Fran?ois Brouillet ve...@mac.com said: I am *NOT* querying about how to create some object graph *programatically*, but how it is possible, if at all, to control drag from one object's outlet in nib#1 to some other target in nib#2 USING INTERFACE BUILDER. It isn't, nor would it make sense to do so. There are no real objects in a nib; there are the names of classes along with instructions on how to instantiate those classes each time the nib is loaded. You can make an outlet from one object to another within the nib because they will all be instantiated together each time the nib is loaded. But an object in another nib might never be instantiated. Or it might be instantiated 1000 times. So a connection such as you describe would be meaningless. Thus it is up to you to organize your architecture so that particular instances that need to see each other can see each other when they both actually exist. Please, prove me wrong and point me to that FAQ :-) You're wrong in the sense that you don't seem to know what a nib is. But now, I hope, you do. :) Now in *another* nib file I have *another* controller and I wanted to tell it: BTW the image you want is in nib file 1, object id 789 That makes no sense because no one would (or could?) keep an *image* in a nib file. An image is not the name of a class; it is a real thing, a resource, an asset; it would be in the app bundle and you'd refer to it with imageNamed: or similar. Also let's make sure you understand about the file's owner. Every nib file has an owner when it is loaded. The owner is an instance that already exists before the nib is loaded, and it is represented inside the nib by a proxy object. That's why you can have outlets to or from the file's owner even though it isn't instantiated from the nib. So if the same object needs to see stuff that comes from two different nibs, you could make it the owner / loader of both nibs - though that would be very unusual. A better way is to start with two instances that can see each other and have one load nib 1 and the other load nib 2. Another possible architecture is that nib 1 is loaded and one of the resulting instances then loads and is owner for another nib - so now that instance, which was instantiated by loading of nib 1, can have outlets to things instantiated by loading nib 2. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ 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
Re: [iPhone] Preprocessing events sent to UITableView
On Jun 6, 2010, at 1:41 AM, WT wrote: Yes, I'm aware of that recommendation. I think that's precisely the core of my question, namely, how to do what I need to do in the safest possible way. I think you need to tell us what the goal you are trying to achieve is, rather than asking how to do it the way you think you should. Then perhaps someone can recommend a better solution. -- David Duncan Apple DTS Animation and Printing ___ 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
Re: detecting touch and hold vs touch in UIButton
On Sat, 05 Jun 2010 21:34:48 -0700, Matt Neuburg m...@tidbits.com said: On Fri, 4 Jun 2010 21:16:50 -0500, Alejandro Marcos Arag?n alejandro.ara...@gmail.com said: I've been trying to detect touch and hold vs touch on a subclass of UIButton. I think you want to imitate Listing 3-3 of Event Handling in the iPhone Application Programming Guide, handling the touches yourself. m. Okay, forget that answer. :) If the difference between touch and touch-and-hold is just a matter of how long the time is between the touch down and the touch up, then all you have to do is measure that time: - (void) userDidTouchDown: (id) sender event: (UIEvent*) e { downtime = [e timestamp]; // downtime is an ivar or global } - (void) userDidTouchUp: (id) sender event: (UIEvent*) e { double diff = [e timestamp] - downtime; if (diff 0.2) NSLog(@tap); else NSLog(@tap and hold); } Obviously Touch Down is targeted at userDidTouchDown:. I think you might want to target both Touch Up Inside and Touch Up Outside at userDidTouchUp:. If you mean something more complex and profound by the difference between touch and touch-and-hold, you can probably figure it out from the UIEvent, so you'd do some more complex and profound form of event tracking here. Anyway, I apologize for being hasty and not very clear before. What I was really trying to say was that all your addition and removal of target-action pairs seems unnecessary. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com ___ 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
Re: [iPhone] Preprocessing events sent to UITableView
On Sun, 6 Jun 2010 10:41:41 +0200, WT jrca...@gmail.com said: question, namely, how to do what I need to do in the safest possible way. I found a solution, but I don't think it's very elegant Sorry if I'm being dense, but did we establish what you *do* need to do? I didn't grasp why you're jumping through all these hoops in the first place. Just curious... Thx. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ 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
Re: detecting touch and hold vs touch in UIButton
Hi Matt, Thanks for your answer. Still, I don't think that solves the problem. It is not just the difference in time what matters. If the user just taps the button, a UISegmentedControl appears, thus this target is in touch up inside. Now, if the user taps and holds, another type of control appears after a delay so this has to be done in touch down (because the user is still holding), and the user should stop holding the button when the new control appears. In your approach, everything is done in the userDidTouchUp, but the tap and hold control should appear even if the user didn't stop holding. If you have a better solution, please let me know, again thanks for your answer. aa On Jun 6, 2010, at 9:35 AM, Matt Neuburg wrote: On Sat, 05 Jun 2010 21:34:48 -0700, Matt Neuburg m...@tidbits.com said: On Fri, 4 Jun 2010 21:16:50 -0500, Alejandro Marcos Arag?n alejandro.ara...@gmail.com said: I've been trying to detect touch and hold vs touch on a subclass of UIButton. I think you want to imitate Listing 3-3 of Event Handling in the iPhone Application Programming Guide, handling the touches yourself. m. Okay, forget that answer. :) If the difference between touch and touch-and-hold is just a matter of how long the time is between the touch down and the touch up, then all you have to do is measure that time: - (void) userDidTouchDown: (id) sender event: (UIEvent*) e { downtime = [e timestamp]; // downtime is an ivar or global } - (void) userDidTouchUp: (id) sender event: (UIEvent*) e { double diff = [e timestamp] - downtime; if (diff 0.2) NSLog(@tap); else NSLog(@tap and hold); } Obviously Touch Down is targeted at userDidTouchDown:. I think you might want to target both Touch Up Inside and Touch Up Outside at userDidTouchUp:. If you mean something more complex and profound by the difference between touch and touch-and-hold, you can probably figure it out from the UIEvent, so you'd do some more complex and profound form of event tracking here. Anyway, I apologize for being hasty and not very clear before. What I was really trying to say was that all your addition and removal of target-action pairs seems unnecessary. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com ___ 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
Re: detecting touch and hold vs touch in UIButton
Hi Roland, Thanks for answering my question. Shouldn't this be very restrictive though? I don't know the statistics, but I'm pretty sure that there is a large number of people having an old version of the OS. aa On Jun 5, 2010, at 10:04 PM, Roland King wrote: or if you are coding for 3.2 or later, use a UILongPressGestureRecognizer and let it do all the work. On 06-Jun-2010, at 12:36 AM, Scott Andrew wrote: I believe the way to do this is to setup a timer on touchDown to fire once after X number of seconds. Your touchUp and touchCancelled should kill the timer if the timer is exists and is not invalidated. If you hit the timer you are being held. When the timer is hit you restart the timer again for the next check. Scott On Jun 4, 2010, at 7:16 PM, Alejandro Marcos Aragón wrote: Hi all, I've been trying to detect touch and hold vs touch on a subclass of UIButton. I basically accomplished that by doing the following: I first add the following when the button is created: [button addTarget:self action:@selector(sourceSelected:) forControlEvents:UIControlEventTouchUpInside]; [button addTarget:self action:@selector(sourceTouchDown:) forControlEvents:UIControlEventTouchDown]; Then in the functions: - (void) sourceSelected:(UIButton*) sender { // cancel request for extended meny [NSObject cancelPreviousPerformRequestsWithTarget:self selector:@selector(sourceSelectedExtended:) object:sender]; ... } - (void) sourceTouchDown:(UIButton*) sender { // give time before performing action [self performSelector:@selector(sourceSelectedExtended:) withObject:sender afterDelay:0.5]; } - (void) sourceSelectedExtended:(UIButton*) sender { // remove action from button [sender removeTarget:self action:@selector(sourceSelected:) forControlEvents:UIControlEventTouchUpInside]; ... ... // give time before performing action [self performSelector:@selector(addSourceAction:) withObject:sender afterDelay:1.]; } - (void) addSourceAction:(UIButton*)sender { // remove action from button [sender addTarget:self action:@selector(sourceSelected:) forControlEvents:UIControlEventTouchUpInside]; } Now, this works fine, but then I thought there must be an easier (and definitely more elegant) way to accomplish the same thing. Can someone through me a line here? Thank you all, aa ___ 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/scottandrew%40roadrunner.com This email sent to scottand...@roadrunner.com ___ 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/rols%40rols.org This email sent to r...@rols.org ___ 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
AUTO: Bill Abt is out of the office. (returning 06/14/2010)
I am out of the office until 06/14/2010. I am currently attending WWDC in SF. I will be checking email periodically. If absolutely needed please contact via cell or via my iPhone email, b...@me.com. Note: This is an automated response to your message Cocoa-dev Digest, Vol 7, Issue 622 sent on 6/6/10 5:41:49. This is the only notification you will receive while this person is away.___ 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
Re: detecting touch and hold vs touch in UIButton
On or about 6/6/10 8:54 AM, thus spake Alejandro Marcos Aragón alejandro.ara...@gmail.com: If the user just taps the button, a UISegmentedControl appears, thus this target is in touch up inside. Now, if the user taps and holds, another type of control appears after a delay so this has to be done in touch down (because the user is still holding), and the user should stop holding the button when the new control appears. Okay, so obviously you then also use performSelector as you were doing, because you have to respond a certain amount of time after the touch starts if the touch has not ended. But you still don't need to add and remove target-action pairs. - (void) tapAndHold { NSLog(@respond to tap and hold); } - (void) userDidTouchDown: (id) sender event: (UIEvent*) e { downtime = [e timestamp]; [self performSelector:@selector(tapAndHold) withObject:nil afterDelay:0.4]; } - (void) userDidTouchUp: (id) sender event: (UIEvent*) e { double diff = [e timestamp] - downtime; if (diff 0.3) { [[self class] cancelPreviousPerformRequestsWithTarget:self]; NSLog(@respond to tap); } } The numbers are up to you, of course. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ pantes anthropoi tou eidenai oregontai phusei Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide, 2nd edition http://www.tidbits.com/matt/default.html#applescriptthings Take Control of Exploring Customizing Snow Leopard http://tinyurl.com/kufyy8 RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html TidBITS, Mac news and reviews since 1990, http://www.tidbits.com ___ 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
changing NSTextView text colour
I have a NSTextView that's displaying MIDI info from my app's current MIDI input device. I show this info in a couple of places - one is in a MIDI Setup type window, and the other is in an Inspector window. I want the Inspector window to show this data in light grey text against a dark background (whereas the MIDI Setup window shows it in black on white). I'm doing this from my MIDI controller class, which is instantiated as a nib in IB. The controller has an IBOutlet to the desired text view. In the controller's init I tried just setting the foreground colour of my text view's textStorage, but that didn't work -- it still displays as black text. It does work to do this: [[mainWindowMIDIMonitor textStorage] setForegroundColor:[NSColor lightGrayColor]]; [mainWindowMIDIMonitor performSelectorOnMainThread:@selector(setString:) withObject:monitorInfo waitUntilDone:NO]; But it doesn't display the first input in light grey. It starts out as black, than changes after the first entry... go figure... Is there no way to just permanently set the text colour to light grey once? Do I have to have the controller hold a reference to the text view, rather than just using an outlet? J. James B Maxwell Composer/Doctoral Student School for the Contemporary Arts (SCA) School for Interactive Arts + Technology (SIAT) Simon Fraser University jbmaxw...@rubato-music.com jbmax...@sfu.ca ___ 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
Re: detecting touch and hold vs touch in UIButton
You still need that timer. Especially for non 3.2. If you get your touchEnded before your timer is reached it was just a tap. Scott Sent from my iPad On Jun 6, 2010, at 8:54 AM, Alejandro Marcos Aragón alejandro.ara...@gmail.com wrote: Hi Matt, Thanks for your answer. Still, I don't think that solves the problem. It is not just the difference in time what matters. If the user just taps the button, a UISegmentedControl appears, thus this target is in touch up inside. Now, if the user taps and holds, another type of control appears after a delay so this has to be done in touch down (because the user is still holding), and the user should stop holding the button when the new control appears. In your approach, everything is done in the userDidTouchUp, but the tap and hold control should appear even if the user didn't stop holding. If you have a better solution, please let me know, again thanks for your answer. aa On Jun 6, 2010, at 9:35 AM, Matt Neuburg wrote: On Sat, 05 Jun 2010 21:34:48 -0700, Matt Neuburg m...@tidbits.com said: On Fri, 4 Jun 2010 21:16:50 -0500, Alejandro Marcos Arag?n alejandro.ara...@gmail.com said: I've been trying to detect touch and hold vs touch on a subclass of UIButton. I think you want to imitate Listing 3-3 of Event Handling in the iPhone Application Programming Guide, handling the touches yourself. m. Okay, forget that answer. :) If the difference between touch and touch-and-hold is just a matter of how long the time is between the touch down and the touch up, then all you have to do is measure that time: - (void) userDidTouchDown: (id) sender event: (UIEvent*) e { downtime = [e timestamp]; // downtime is an ivar or global } - (void) userDidTouchUp: (id) sender event: (UIEvent*) e { double diff = [e timestamp] - downtime; if (diff 0.2) NSLog(@tap); else NSLog(@tap and hold); } Obviously Touch Down is targeted at userDidTouchDown:. I think you might want to target both Touch Up Inside and Touch Up Outside at userDidTouchUp:. If you mean something more complex and profound by the difference between touch and touch-and-hold, you can probably figure it out from the UIEvent, so you'd do some more complex and profound form of event tracking here. Anyway, I apologize for being hasty and not very clear before. What I was really trying to say was that all your addition and removal of target-action pairs seems unnecessary. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com ___ 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/scottandrew%40roadrunner.com This email sent to scottand...@roadrunner.com ___ 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
Re: detecting touch and hold vs touch in UIButton
On or about 6/6/10 11:04 AM, thus spake Scott Andrew scottand...@roadrunner.com: You still need that timer. Especially for non 3.2. If you get your touchEnded before your timer is reached it was just a tap. Right, but my revised solution (which you do not quote) with performSelector and delayed performance *is* effectively using a timer. I tested on 3.1.2 and it seems to do exactly what the OP asked for. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ pantes anthropoi tou eidenai oregontai phusei Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide, 2nd edition http://www.tidbits.com/matt/default.html#applescriptthings Take Control of Exploring Customizing Snow Leopard http://tinyurl.com/kufyy8 RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html TidBITS, Mac news and reviews since 1990, http://www.tidbits.com ___ 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
Re: detecting touch and hold vs touch in UIButton
Hi Matt, thanks for clarifying that. That worked like a charm! I had to override functions: - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event; - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event; But it works just as I want. Thanks again! aa On Jun 6, 2010, at 11:11 AM, Matt Neuburg wrote: On or about 6/6/10 8:54 AM, thus spake Alejandro Marcos Aragón alejandro.ara...@gmail.com: If the user just taps the button, a UISegmentedControl appears, thus this target is in touch up inside. Now, if the user taps and holds, another type of control appears after a delay so this has to be done in touch down (because the user is still holding), and the user should stop holding the button when the new control appears. Okay, so obviously you then also use performSelector as you were doing, because you have to respond a certain amount of time after the touch starts if the touch has not ended. But you still don't need to add and remove target-action pairs. - (void) tapAndHold { NSLog(@respond to tap and hold); } - (void) userDidTouchDown: (id) sender event: (UIEvent*) e { downtime = [e timestamp]; [self performSelector:@selector(tapAndHold) withObject:nil afterDelay:0.4]; } - (void) userDidTouchUp: (id) sender event: (UIEvent*) e { double diff = [e timestamp] - downtime; if (diff 0.3) { [[self class] cancelPreviousPerformRequestsWithTarget:self]; NSLog(@respond to tap); } } The numbers are up to you, of course. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ pantes anthropoi tou eidenai oregontai phusei Among the 2007 MacTech Top 25, http://tinyurl.com/2rh4pf AppleScript: the Definitive Guide, 2nd edition http://www.tidbits.com/matt/default.html#applescriptthings Take Control of Exploring Customizing Snow Leopard http://tinyurl.com/kufyy8 RubyFrontier! http://www.apeth.com/RubyFrontierDocs/default.html TidBITS, Mac news and reviews since 1990, http://www.tidbits.com ___ 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
personalized segmented control, like the copy paste one
Hi all, I was trying to find in the documentation if it is possible to use a segmented control like the one used for copy paste (with a little arrow pointing to the field you're editing), but couldn't find anything. Is it possible to do such a thing? If so, is it difficult to implement? Do I have to subclass the UISegmentedControl and change the way it's drawn on screen? Thank you, aa ___ 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
Re: personalized segmented control, like the copy paste one
On Jun 6, 2010, at 11:55 AM, Alejandro Marcos Aragón alejandro.ara...@gmail.co m wrote: Hi all, I was trying to find in the documentation if it is possible to use a segmented control like the one used for copy paste (with a little arrow pointing to the field you're editing), but couldn't find anything. Is it possible to do such a thing? If so, is it difficult to implement? Do I have to subclass the UISegmentedControl and change the way it's drawn on screen? Starting in OS 3.2, you can add custom items to the Edit menu, as this widget is called. Of course this doesn't help you right now if you're targeting the iPhone. But I hear there's gonna be a big media event tomorrow in the San Francisco area, and some phone manufacturer might make some announcements. ;-) --Kyle Sluder (Sent from the road) Thank you, aa ___ 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
NSTextField sending action unbidden...
Dear programmers, I have a textfield which is spontaneously sending out an action. I have it set to send on end editing but when the nib loads and I click on any part of the window it sends an action which then messes up other stuff... Is there some value I can set so that it sends on hitting return only? Matthew Weinstein Associate Professor of Science Education Education Program U.W. - Tacoma 253 692-4787 matth...@u.washington.edu Campus Box: 358435 1900 Commerce Street Tacoma, WA 98402-3100 Office: (253) 692-4787 FAX: (253) 692-5612 ___ 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
Re: Cocoa-dev Digest, Vol 7, Issue 621
On Jun 5, 2010, at 10:17 PM, cocoa-dev-requ...@lists.apple.com wrote: I'm new to Cocoa programming. I would like to be able to drag filenames from Finder to a custom view in my application. Both previous mails and Mr. Google redirect to Drag and Drop Programming Topics for Cocoa (http://developer.apple.com/documentation/Cocoa/Conceptual/DragandDrop/) . I've read this, but something still doesn't work. I just went through this same exercise some very nice folks on this list pointed me in the right direction. I will send you some working code off line. However, changing the line: [self registerForDraggedTypes: [NSArray arrayWithObject: NSFilenamesPboardType]]; to [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]]; might help. ronald b. kopelman___ 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
Ignore last problem...
Sometimes wording confuses: I read send on enter as meaning send on beginning rather than as the enter key. Mathew ___ 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
Re: NSTextField sending action unbidden...
On Jun 6, 2010, at 12:14 PM, Matthew Weinstein wrote: I have a textfield which is spontaneously sending out an action. I have it set to send on end editing but when the nib loads and I click on any part of the window it sends an action which then messes up other stuff… Hm. “Send on end editing” means “send when it loses focus”, so if the field has focus when the window loads, then the first time you click on some other focusable control you’ll get that behavior. Or is that different from what you’re seeing? —Jens___ 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
Re: registering dragged types
On Jun 6, 2010, at 12:25 PM, ronald b. kopelman wrote: However, changing the line: [self registerForDraggedTypes: [NSArray arrayWithObject: NSFilenamesPboardType]]; to [self registerForDraggedTypes:[NSArray arrayWithObjects:NSFilenamesPboardType, nil]]; might help. No, those two NSArray calls have exactly the same effect, creating an array with a single object. I prefer the first since it’s shorter and you don’t have to remember to put the “,nil” at the end. (At least you get a compiler warning in 10.5+ if you forget. It used to just crash at runtime.) —Jens PS: When replying to a digest, remember to update the subject line to match the message you’re replying to, so it’s not the generic “Re: Cocoa-dev Digest…”. Thanks.___ 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
SQLite Database 2 distinct database iphone.
Greetings. I'm building a iPhone application which is database driven. in that application i've designed it to have two databases. One database will be distributed with the application and is meant to be read only. the second database is meant to copy items to it for the user's safe keeping. the reason for this is that the application update will also include a refreshed database and as such if i only link to the records it might happen that the record that the user wished to keep would of been purged from the original database. evidently the structure is quite the same on both, with the exception of some additional fields in the user database. when the application starts it complains that it can not merge the two models. i've been looking on the net but found nothing of significance. is it possible to have two separate database in the same application on the iphone. and what are the steps to make it happen. do i have to duplicate the Core data initialization procedures and maintain 2 distinct managed object contexts? thank you for any pointers. Best regards. Sandro Noel.___ 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
Re: Cross XIB references?
Thank you all for hammering this down, maybe I needed it :) I completely forgot about the unique superview thing, and didn't know about the actual bit sharing that UIImage could perform, both of which do settle my use case as a no-no. Thanks. Now in *another* nib file I have *another* controller and I wanted to tell it: BTW the image you want is in nib file 1, object id 789 That makes no sense because no one would (or could?) keep an *image* in a nib file. An image is not the name of a class; it is a real thing, a resource, an asset; it would be in the app bundle and you'd refer to it with imageNamed: or similar. As should have been clear with nib file 1, object id 789 I was referring to *references* certainly not image data, that I'm not dumb enough to believe that IB would somehow slurp from the file system and include as an XML binary blob!!! Also let's make sure you understand about the file's owner. Every nib file has an owner when it is loaded. The owner is an instance that already exists before the nib is loaded, and it is represented inside the nib by a proxy object. That's why you can have outlets to or from the file's owner even though it isn't instantiated from the nib. So if the same object needs to see stuff that comes from two different nibs, you could make it the owner / loader of both nibs - though that would be very unusual. A better way is to start with two instances that can see each other and have one load nib 1 and the other load nib 2. Another possible architecture is that nib 1 is loaded and one of the resulting instances then loads and is owner for another nib - so now that instance, which was instantiated by loading of nib 1, can have outlets to things instantiated by loading nib 2. This is very true and I am not disputing that. Since I have been convinced that even trying to share the image _bits_ was futile, I won't attempt this anymore. Anyway, thanks again to all -- JFB ___ 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
Re: Cross XIB references?
On 07/06/2010, at 8:17 AM, Jean-François Brouillet wrote: Since I have been convinced that even trying to share the image _bits_ was futile, I won't attempt this anymore. Sharing the image BITS is not futile, but is not accomplished by referencing objects cross-nib. NSImage will cache and share its image bits more or less automatically as long as you don't stop it from doing so. Referencing the same image by name in two different nibs will share that image. --Graham ___ 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
Re: changing NSTextView text colour
On 07/06/2010, at 3:21 AM, James Maxwell wrote: Do I have to have the controller hold a reference to the text view, rather than just using an outlet? I don't know the answer to the problem, but just to pick up on this one - an outlet IS a reference to the object it's connected to, nothing more or less. --Graham ___ 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
Re: changing NSTextView text colour
On Jun 6, 2010, at 1:21 PM, James Maxwell wrote: I have a NSTextView that's displaying MIDI info from my app's current MIDI input device. I show this info in a couple of places - one is in a MIDI Setup type window, and the other is in an Inspector window. I want the Inspector window to show this data in light grey text against a dark background (whereas the MIDI Setup window shows it in black on white). I'm doing this from my MIDI controller class, which is instantiated as a nib in IB. The controller has an IBOutlet to the desired text view. In the controller's init I tried just setting the foreground colour of my text view's textStorage, but that didn't work -- it still displays as black text. It does work to do this: [[mainWindowMIDIMonitor textStorage] setForegroundColor:[NSColor lightGrayColor]]; [mainWindowMIDIMonitor performSelectorOnMainThread:@selector(setString:) withObject:monitorInfo waitUntilDone:NO]; But it doesn't display the first input in light grey. It starts out as black, than changes after the first entry... go figure... Is there no way to just permanently set the text colour to light grey once? Do I have to have the controller hold a reference to the text view, rather than just using an outlet? This might help; forgive me if it doesn't address your situation. In an NSTextStorage object, text attributes are values that apply to some range of text in the object. If the object has no text, then setting attributes is meaningless. If a textStorage length is 0, and you set a foreground color attribute, and subsequently add some text, the text does not necessarily show up with that foreground color. When plain text without attributes is added to a textStorage object--as, for example, with input from the keyboard--the NSTextView uses its typingAttributes dictionary to apply attributes to the new text. So, if you've got a new NSTextView whose NSTextStorage length is 0, and you are going to add some plain text to it, you must first set the typingAttributes of the NSTextView to the desired attributes. -setForegroundColor: is one of the scriptability methods of NSTextStorage. Those methods are not recommended for use in non-scripting situations. ___ 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
Problems with Pinyin Simplified Chinese text input
Hi, I have a canvas view which has a whole lot of text views as subviews. When a person types a letter while the canvas is the first responder, I want to change the first responder to the appropriate text view and replace anything in that text view with the letter typed. In my canvas view, I implement the NSTextInputClient, and in my -insertText:replacementRange: method, I find the appropriate text view, select all the text, make it selectable and editable, and make it the first responder, then use -insetText: on the text view to put the text there. This works fine for English, and for composed characters like U with an umlaut (Option U, U), and for other input methods e.g. Hirgana, but I am having two problems with the Pinyin simplified input method: 1. Sometimes, the text view has just the first letter showing and the character selection panel is displayed at the bottom left of my main screen. It still works, but just isn't in the right place. 2. Sometimes, the first character typed is repeated twice in the text field, and the character selection panel is displayed in the right place. I'd really appreciate an suggestions as to how to resolve this issue. The deployment of this application is 10.5/10.6. Thanks. Gideon ___ 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
Re: changing NSTextView text colour
Well, yes, I figured as much... just grasping at straws, really. What I don't get is why using the Text colour panel in IB doesn't actually set the text colour for the text view. Strange. Seems wildly counter-intuitive, to me. Anyway, I am able to get the text colour changed, it's just this annoying little thing that the text changes only *after* the first line has been shown -- once the first line of black text has been rendered, everything after that comes up in the desired light grey. I'll fix it at some point, but it's not a huge priority, at the moment. If anyone has any thoughts, let me know. J. On 2010-06-06, at 3:50 PM, Graham Cox wrote: On 07/06/2010, at 3:21 AM, James Maxwell wrote: Do I have to have the controller hold a reference to the text view, rather than just using an outlet? I don't know the answer to the problem, but just to pick up on this one - an outlet IS a reference to the object it's connected to, nothing more or less. --Graham James B Maxwell Composer/Doctoral Student School for the Contemporary Arts (SCA) School for Interactive Arts + Technology (SIAT) Simon Fraser University jbmaxw...@rubato-music.com jbmax...@sfu.ca ___ 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
NSTableView action doubleAction...
Dear Programmers, I set both my tableView's actions and doubleActions programmatically in my document's windowdidloadnib... I find that if I double click It calls both! Is this expected behavior? Is there a method to this madness? Matthew Weinstein Associate Professor of Science Education Education Program U.W. - Tacoma 253 692-4787 matth...@u.washington.edu Campus Box: 358435 1900 Commerce Street Tacoma, WA 98402-3100 Office: (253) 692-4787 FAX: (253) 692-5612 ___ 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
Re: changing NSTextView text colour
hmm... okay. I get what you're saying about range, and I did wonder about that, but it seems strange to be required to always set it by range, for each line. Shouldn't there just be a single, persistent setting -- a default, as it were? I'll look at the typingAttributes, but this text is being set programmatically, not by the user. Don't know if that makes a difference... (Typing certainly sounds like user input to me.) As I say, I would have expected the IB Attributes panel to be able to set it, but it's not working, for whatever reason. J. On 2010-06-06, at 5:29 PM, Ross Carter wrote: On Jun 6, 2010, at 1:21 PM, James Maxwell wrote: I have a NSTextView that's displaying MIDI info from my app's current MIDI input device. I show this info in a couple of places - one is in a MIDI Setup type window, and the other is in an Inspector window. I want the Inspector window to show this data in light grey text against a dark background (whereas the MIDI Setup window shows it in black on white). I'm doing this from my MIDI controller class, which is instantiated as a nib in IB. The controller has an IBOutlet to the desired text view. In the controller's init I tried just setting the foreground colour of my text view's textStorage, but that didn't work -- it still displays as black text. It does work to do this: [[mainWindowMIDIMonitor textStorage] setForegroundColor:[NSColor lightGrayColor]]; [mainWindowMIDIMonitor performSelectorOnMainThread:@selector(setString:) withObject:monitorInfo waitUntilDone:NO]; But it doesn't display the first input in light grey. It starts out as black, than changes after the first entry... go figure... Is there no way to just permanently set the text colour to light grey once? Do I have to have the controller hold a reference to the text view, rather than just using an outlet? This might help; forgive me if it doesn't address your situation. In an NSTextStorage object, text attributes are values that apply to some range of text in the object. If the object has no text, then setting attributes is meaningless. If a textStorage length is 0, and you set a foreground color attribute, and subsequently add some text, the text does not necessarily show up with that foreground color. When plain text without attributes is added to a textStorage object--as, for example, with input from the keyboard--the NSTextView uses its typingAttributes dictionary to apply attributes to the new text. So, if you've got a new NSTextView whose NSTextStorage length is 0, and you are going to add some plain text to it, you must first set the typingAttributes of the NSTextView to the desired attributes. -setForegroundColor: is one of the scriptability methods of NSTextStorage. Those methods are not recommended for use in non-scripting situations. ___ 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/jbmaxwell%40rubato-music.com This email sent to jbmaxw...@rubato-music.com James B Maxwell Composer/Doctoral Student School for the Contemporary Arts (SCA) School for Interactive Arts + Technology (SIAT) Simon Fraser University jbmaxw...@rubato-music.com jbmax...@sfu.ca ___ 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
Re: Notification of window visible?
Is it? Can't a window become visible without becoming key? - Original Message From: Reinhard Segeler macmeid...@googlemail.com To: Chris Idou idou...@yahoo.com Cc: cocoa-dev@lists.apple.com Sent: Fri, 4 June, 2010 4:18:03 PM Subject: Re: Notification of window visible? The notification NSWindowDidBecomeKeyNotification will do it for you. -- Reinhard Am 04.06.2010 um 07:11 schrieb Chris Idou: How does one get notification that a window has become visible? I can see notifications for most every type of window event except this most obvious one. ___ 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/macmeideln%40googlemail.com This email sent to macmeid...@googlemail.com ___ 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
Re: NSTableView action doubleAction...
On Sun, 6 Jun 2010 18:12:07 -0700, Matthew Weinstein mwein...@kent.edu said: I set both my tableView's actions and doubleActions programmatically in my document's windowdidloadnib... I find that if I double click It calls both! You're doing both. :) The only way to tell the difference is to delay after the first click to see whether there's a second (just like the way you tell the difference between single and double-tap on iPhone). I guess the question is why you want to do this in the first place. I've written lots of applications where double-clicking in a table did something, and in *none* of them did I also need to implement something for single-clicking. I get an event (thru the delegate) when the selection changes and *that* is usually what I'm interested in. (Actually, in this modern age, it's usually enough to let bindings handle the selection change.) Do you really want something utterly special and unique to happen when the user single-clicks on a row that is already selected? That would be a very strange interface; the user is likely to be very surprised. If you want to make that sort of thing clear, I'd suggest you put a button in the row and catch the click from *that*. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ 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
Re: NSTableView action doubleAction...
Actually I'm really happy it does both; I just want to count on it doing both. In my case it is really important that the single click do something before the 2nd click. I want users to be able to single click without triggering the subsequent action, the double click takes the single click and applies that action to a selection in a textview. So it works fine. I just want to make sure that I'm not counting on a bug or some other defect (in my very meager programming skills or apple's api). On Jun 6, 2010, at 6:44 PM, Matt Neuburg wrote: On Sun, 6 Jun 2010 18:12:07 -0700, Matthew Weinstein mwein...@kent.edu said: I set both my tableView's actions and doubleActions programmatically in my document's windowdidloadnib... I find that if I double click It calls both! You're doing both. :) The only way to tell the difference is to delay after the first click to see whether there's a second (just like the way you tell the difference between single and double-tap on iPhone). I guess the question is why you want to do this in the first place. I've written lots of applications where double-clicking in a table did something, and in *none* of them did I also need to implement something for single-clicking. I get an event (thru the delegate) when the selection changes and *that* is usually what I'm interested in. (Actually, in this modern age, it's usually enough to let bindings handle the selection change.) Do you really want something utterly special and unique to happen when the user single-clicks on a row that is already selected? That would be a very strange interface; the user is likely to be very surprised. If you want to make that sort of thing clear, I'd suggest you put a button in the row and catch the click from *that*. m. -- matt neuburg, phd = m...@tidbits.com, http://www.tidbits.com/matt/ A fool + a tool + an autorelease pool = cool! AppleScript: the Definitive Guide - Second Edition! http://www.tidbits.com/matt/default.html#applescriptthings ___ 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
Re: changing NSTextView text colour
On Sun, Jun 6, 2010 at 10:21 AM, James Maxwell jbmaxw...@rubato-music.com wrote: I have a NSTextView that's displaying MIDI info from my app's current MIDI input device. I show this info in a couple of places - one is in a MIDI Setup type window, and the other is in an Inspector window. I want the Inspector window to show this data in light grey text against a dark background (whereas the MIDI Setup window shows it in black on white). I'm doing this from my MIDI controller class, which is instantiated as a nib in IB. The controller has an IBOutlet to the desired text view. In the controller's init I tried just setting the foreground colour of my text view's textStorage, but that didn't work -- it still displays as black text. It does work to do this: [[mainWindowMIDIMonitor textStorage] setForegroundColor:[NSColor lightGrayColor]]; [mainWindowMIDIMonitor performSelectorOnMainThread:@selector(setString:) withObject:monitorInfo waitUntilDone:NO]; Probably not related to your immediate problem, but I wanted to point out that this code is unsafe. I assume you're using performSelectorOnMainThread: because this code is running on a background thread. If that's the case, then your first line is dangerous, because NSTextView is not thread safe. You should run both lines of code (and anything else manipulating any aspect of the view) on the main thread. Mike ___ 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
[ANN] Cocoa Talk
Cocoa Talk is a brand new video blog on cocoa. Check it out at http://cocoatalk.libsyn.com/ This episode concerns UIViews and touches. ___ 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