Using custom controls on top of custom graphics
I want to use a custom graphic as the main window of a program, and I'm using custom controls (built with NSButtons on top of NSViews). I have not been able to figure out how to make the custom controls appear on top of the bitmap. I also want to build custom sliders using a special graphic for the slider area and for the knob. Can someone point me to some source code that shows how to do this? Thanks, Tom Jeffries ___ 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com
Changing the appearance of buttons
This is probably an elementary question. I need to change the bitmaps used for buttons. Is there a way to do that with buttons created using Interface Builder or do I need to create a new class that gives me control of the bitmaps? If I need to create a new class, is there some example source code available? Thanks, Tom Jeffries ___ 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 the appearance of buttons
Mac. sent from my mobile phone On Nov 8, 2011 1:37 PM, Mike Abdullah cocoa...@mikeabdullah.net wrote: Mac or iOS? On 8 Nov 2011, at 18:52, Tom Jeffries wrote: This is probably an elementary question. I need to... ___ 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/cocoadev%40mikeabdullah.net This email sent to cocoa...@mikeabdullah.net ___ 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
drawRect not getting called problem solved
I appreciate all the comments on the problem I had with drawRect not getting called. I finally extracted the code that was not working and put it in a new program, and it worked perfectly. I'm still not sure whether there was a problem in my code or if I unearthed a problem in Cocoa, but I'm now adding the rest of the original program to the new program, and the graphics are working. I understand that people who program in only one environment want to see code that matches the way they learned to program. That causes problems for those of us who work in multiple environments, some of which have a whole different set of rules. However, maybe it's a sign that software development is still at an early stage that some environments insist on Data and others insist on data. I do think it's important to keep in mind the difference between code and data, and some of the suggestions I got seemed to show some lack of clarity in that area. Confusing the two may work in certain specific environments, but it reflects a misunderstanding of the way computers actually work. I think it's important to have an awareness of the difference. Thanks again for your help. ___ 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
More on drawRect not getting called
I appreciate the answers, so far everything that's been suggested is something I've tried. Maybe if I put the code out somebody will see what I'm doing wrong: This is the function that is called by the mouse click, it's in another module: + (BOOL) Play { // init code [SequeraStepWindow DrawCurrentBarNotes]; } It calls this function in the NSView module: - (void) DrawCurrentBarNotes { drawNotesFlag = YES; // This flag tells drawRect to draw the notes next time [self DrawNotes]; // this is where the drawing takes place I've tried all of these to invoke drawRect, no luck //[self awakeFromNib]; //[super awakeFromNib]; //[SequeraStepWindow awakeFromNib]; //[SequeraStepWindow setNeedsDisplay: YES]; //[self setNeedsDisplay: YES]; //[super setNeedsDisplay: YES]; } Here's drawRect, which gets called properly on start up but does not get called afterwards - (void)drawRect:(NSRect)dirtyRect { [self DrawStepArea]; // Always draw the step area // don't draw the notes on program startup if(drawNotesFlag == YES) // if I comment this out DrawNotes works fine [self DrawNotes]; } Somebody suggested using NSLog, which I haven't done. However I've been using breakpoints and tracing through the code, which I assume should be just as valid. Everything works perfectly- except drawRect doesn't get called. ___ 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: More on drawRect not getting called
Jens, I'm sorry if my naming conventions confuse you. I've been programming for 27 years on a wide variety of operating systems, and I'm afraid following Cocoa naming conventions is not high on my list. I thought [SequeraStepWindow awakeFromNib] makes it obvious that SequeraStepWindow is a class. Is there a way to use that syntax with a variable? If so, Objective C gets a major thumbs down. Draw Notes calls other routines to get the correct information and ends with: CGContextBeginPath (noteContext); CGContextAddEllipseInRect(noteContext, noteBox); CGContextFillPath(noteContext); CGContextDrawPath(noteContext, kCGPathStroke); drawRect is supposed to do the actual screen drawing. It does it perfectly when called during program startup. It is not called again. The program compiles without warnings. Obviously I dealt with that level before posting a question here. Thanks, Tom On Sun, Jul 24, 2011 at 10:45 AM, Jens Alfke j...@mooseyard.com wrote: On Jul 24, 2011, at 10:11 AM, Tom Jeffries wrote: + (BOOL) Play It’s hard to tell what’s going on in the code when you’re not following Cocoa naming conventions. Methods should start with a lowercase letter (unless they begin with a common acronym like “URL”). I’m very strongly in favor of prefixing (or postfixing) instance variables with something like “_” or “m_” to distinguish them from other variables. This makes it a lot easier to look at code and quickly identify what a variable is, as in these snippets. (It’s not a universal convention, though, although I will note that Apple strongly follows it in its own code.) [self DrawNotes]; // this is where the drawing takes place Do you mean that the -DrawNotes method actually draws stuff? It shouldn’t; that should happen in -drawRect:. //[SequeraStepWindow awakeFromNib]; //[SequeraStepWindow setNeedsDisplay: YES]; What is SequeraStepWindow? A class or a variable? It’s capitalized so I assume a class, but both of those are instance methods, so they won’t work when called on a class (and will generate compiler warnings.) * Does your code build without warnings? If not, fix the warnings first. Very important; a lot of serious errors in Obj-C only get reported as warnings. * Have you set an all-exceptions breakpoint? There are cases in which an exception thrown from your code can be caught by AppKit and not reported back to you, so it just looks as though nothing happens. This is getting messy enough that maybe you should just upload a zip file of your whole project, or at least the relevant source files, and post the URL... —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: More on drawRect not getting called
Patrick, Everything works except that I can't get drawRect to be called a second time. I assume that means the IBOutlet is working. However, I think you're right that there's something about the interaction between the modules that is causing the problem. Thanks, Tom On Sun, Jul 24, 2011 at 11:38 AM, Patrick William Walker patrick.william.wal...@nb.sympatico.ca wrote: On 2011-07-24, at 2:11 PM, Tom Jeffries wrote: I appreciate the answers, so far everything that's been suggested is something I've tried. Maybe if I put the code out somebody will see what I'm doing wrong: This is the function that is called by the mouse click, it's in another module: + (BOOL) Play { // init code [SequeraStepWindow DrawCurrentBarNotes]; } It's hard to see what you've done. One thing to check is to make sure you have correctly added in (and connected) an IBOutlet inside your NIB/XIB file. You can send [myView setNeedsDisplay: YES] over and over and nothing will happen and is a common oversight. Is your custom view is configured property (and connected) under your SequeraStepWindow? I'm not sure why you've defined + (BOOL) Play as a class method but without seeing more of the actual code I cannot say much more. Is your custom view is configured property (and connected) under your SequeraStepWindow? Patrick William Walker patrick.william.wal...@nb.sympatico.ca patrickwilliamwal...@yahoo.com will.wal...@unb.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: More on drawRect not getting called
On Sun, Jul 24, 2011 at 12:12 PM, Andy Lee ag...@mac.com wrote: You should know that it is most certainly possible to use that syntax with a variable. For example: NSString *myString = @abc; // == a variable NSString *newString = [myString copy]; // == a message send You can send messages to both classes and instances of classes. If you are not clear about the difference between a class and an instance, let us know now so we can proceed on the same page. OK, we're each half right- myString in this case is a function, not a class, but I would question calling it a variable. Maybe I'm old fashioned, but I think it's important to distinguish between information (variables) and operations (functions). That is one reason why I'm less than completely enthusiastic about Objective C syntax and Cocoa conventions. However, I do understand that using them would make it easier to understand what's going on. I've gotten several interesting hints from the comments, which I appreciate. I'm going to pursue them, if I don't find a solution I'll see if I can post a more understandable example. Thanks, Tom ___ 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
drawRect not getting called when needed under OS X
I am using a window that uses a subclass of NSView. Part of it is drawn when the program starts, another part needs to be drawn when the user clicks on a button in another window. The code for the other window calls my subclass of NSView with no problems, creates the new graphics, and then returns. However, the window that needs to get updated with new graphics does not change. When I put both the beginning graphics and the graphics that are to be drawn later in the initial drawRect call everything is drawn without a problem. However, drawRect does not get called when the user clicks the button on the second window. I've tried awakeFromNib, setNeedsDisplay, needsDisplay, and display, but nothing I've found so far gets the NSView window to call drawRect. I am fairly new to OS X programming and appreciate any hints you can throw my way. Thanks, Tom Jeffries ___ 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: drawRect not getting called when needed under OS X
Graham, I'm not calling drawRect. The button click goes to another module in the program, all the code in that module works fine, then it calls the module that has the NSView, executes the code for creating all the lines and shapes, and then tries to get the new graphics to display. I've tried (among other things): [super setNeedsDisplay : YES]; [SequeraStepWindow setNeedsDisplay : YES]; [self setNeedsDisplay : YES]; [SequeraStepWindow display]; [self display]; [super display]; When I run the code that displays the graphics in question on initialization it works fine, but when I call it later in the program it the new graphics are not displayed. The code in the graphics module that displays the window is working perfectly, but somehow drawRect never gets called after it is called during initialization. On Sat, Jul 23, 2011 at 9:06 PM, Graham Cox graham@bigpond.com wrote: On 24/07/2011, at 1:46 PM, Tom Jeffries wrote: When I put both the beginning graphics and the graphics that are to be drawn later in the initial drawRect call everything is drawn without a problem. However, drawRect does not get called when the user clicks the button on the second window. I've tried awakeFromNib, setNeedsDisplay, needsDisplay, and display, but nothing I've found so far gets the NSView window to call drawRect. I am fairly new to OS X programming and appreciate any hints you can throw my way. Show your code. You don't call drawRect: - the framework does. You can tell the framework it needs to be called by calling the view's -setNeedsDisplay: method. Are you doing that? How does the button come into it? How are you responding to the button? That's the trouble - what you've said so far is far too vague, it could be a thousand different things (but probably something simple). --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
Building, installing, and testing drivers
I'm building a MIDI-in driver that will be bringing in MIDI data from Wifi, and I'm having trouble figuring out certain configuration details. I started with the SampleUSBDriver and eliminated the USB code and got it compiling correctly. However, the documentation seems to be based on earlier versions of XCode. I have some specific questions: - The docs say I need to put the UUID in the project's bundle settings. Where are they? - There are a series of CFPlugIn settings, where are they? I'm talking about CFPlugInDynamicRegistration, CFPlugInFactories, CFPlugInTypes - How do I build an install for the drivers? Thanks, Tom Jeffries ___ 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
Using an iPhone to control a Mac- source code?
This may be the wrong forum for this question- if so, please let me know. I want to use an iPhone to act as mouse and keyboard for a Mac. It looks like the best connection is through a network, although Bluetooth might also work. There are other apps that do this. I'd love some sample code so I don't have to wade through the whole networking protocol. Suggestions? Thanks, Tom Jeffries ___ 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
Refreshing an NSView
I seem to be missing something, and it's probably something quite obvious. In the initialization to an NSView subclass window, I do the following: - (void) drawRect:(NSRect)dirtyRect { [StepWindow DrawStepArea]; } DrawStepArea is a simple function that draws some lines on the screen- here's a condensed version: + (void) DrawStepArea { CGRect stepsBox; CGContextRef stepsContext = [[NSGraphicsContext currentContext] graphicsPort]; CGContextSetLineWidth(stepsContext, 1.0); stepsBox = CGRectMake(0, 0, 100, 100); CGContextBeginPath (stepsContext); CGContextSetRGBStrokeColor(stepsContext, 0, 0, 0, 1); CGContextAddRect(stepsContext, stepsBox); CGContextFillPath(stepsContext); CGContextDrawPath (stepsContext, kCGPathStroke); } It works perfectly when the window is first initialized. However, when I call DrawStepArea later nothing gets drawn. I'm calling from another class, but everything about the call works fine including access to variables in the StepWindow class. Any idea what I'm missing, or on what to look for to figure this out? Many thanks for any 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 arch...@mail-archive.com
Keyboard handlers
I need to intercept repeat keys in one window of an application. I see some references from about 10 years ago about the GLUT key handling routines, but they don't seem to work. In particular glutIgnoreKeyRepeat(TRUE) does not do anything. Should I be using other code? Is there a better way to trap events? NSEvent looks like it might work, is there any sample code I can reference? Thanks for any help, Tom Jeffries ___ 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