Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

adimex

macrumors newbie
Original poster
Hello all,
I am trying to do something like this in Cocoa:
VB6pins.jpg


User clicks in the window and my Object (in this case, a UserControl with a drop pin appears where the user clicked). If the user clicks on the drop pin, another window will popup with information etc...

How would I go about replicating a graphical object? Obj-C objects are piece of cake (UserControl *UC = [[UserControl alloc] init];...) but I can't seem to make it happen with graphical objects.

VB Codes looks something like this:

private sub form1_mouseDown(x as int, y as int)
dim i as integer
i = userControl.count

load userControl(i)
userControl(i).move x, y
end sub

thanks!!!
D.
 
Well, technically, graphical objects *are* Objective-C objects, so you do the same thing, but there's more to displaying a graphical object than simply creating it.

Code:
	IBOutlet NSView * m_Output;

...

	NSTextField * pOutput = nil;

	NSRect frame = { { 0 } };
	pOutput = [[NSTextField [COLOR="Blue"]alloc[/COLOR]] [COLOR="blue"]init[/COLOR]WithFrame: frame];
			
	if ( pOutput )
	{
		[pOutput setStringValue: @"A string"];
		[pOutput autorelease];
	}

...

	[pOutput retain];
	
	[m_ParentView addSubview: pOutput];
	[m_ParentView setAutoresizesSubviews: YES];
	[pOutput setAutoresizingMask: ( NSViewWidthSizable | NSViewHeightSizable )];
	
	[m_ParentView setFrameSize: [m_ParentView frame].size ];
	[m_ParentView setNeedsDisplay: YES];
	[m_ParentView setNeedsDisplay: YES];

...

That should give you an idea of a few things that might need to be done to make something visible.

Of course, there's more to be done before it will be interactive as well.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.