• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: editWithFrame:inView:editor:delegate:event: in mouseDown:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: editWithFrame:inView:editor:delegate:event: in mouseDown:


  • Subject: Re: editWithFrame:inView:editor:delegate:event: in mouseDown:
  • From: Alexander Spohr <email@hidden>
  • Date: Thu, 20 Nov 2008 12:11:22 +0100


Am 19.11.2008 um 19:27 schrieb Kyle Sluder:

On Wed, Nov 19, 2008 at 7:51 AM, Alexander Spohr <email@hidden> wrote:
I am trying to make a subclass of NSControl that is capable of showing
variable width (and maybe height) content.

Not entirely sure what you're trying to describe here. It almost sounds like you just want to embed your view in an NSScrollView.

No. I want something like a one row NSMatrix. But the cells should have different sizes. Like a row in an NSTableView.
Because there is no such NSControl (to my knowledge) I have to roll my own.



Here is a pseudo-example of
- (void)mouseDown:(NSEvent *)anEvent
{
NSPoint aClickLocation = [self convertPoint:[anEvent locationInWindow] fromView:nil];
NSCell *aCell = [self cellAt:aClickLocation.x];
NSRect aCellFrame = [self frameOfCell:Cell];
if([aCell trackMouse:anEvent inRect:aCellFrame ofView:self untilMouseUp:NO])
{
// mouseDragged & mouseUp are handled by trackMouse:!
NSText *anEditorView = [[self window] fieldEditor:YES forObject:nil];
switch ([anEvent clickCount])
{
case 1:
NSInteger aLength = [[selectedCell content] length];
[aCell selectWithFrame:aCellFrame inView:self editor:anEditorView delegate:self start:0 length:aLength];
break;
case 2:
[self setEditedCell:selectedCell];
[aCell editWithFrame:aCellFrame inView:self editor:anEditorView delegate:self event:anEvent];
break;
default:
break;
}
}
}


I think my use of trackMouse: is wrong.
And I need a working method to get the result back.

This looks too twisted to be right:
- (void)textDidEndEditing:(NSNotification *)aNotification
{
	NSTextView *aTextView = [aNotification object];
	[editedCell setContent:[[[aTextView textStorage] copy] autorelease]];
	[self setEditedCell:nil];
	if([[self window] firstResponder] == aTextView)
		[[self window] makeFirstResponder:self];
	[aTextView removeFromSuperview];
}

So if anybody could slip me some code under the table to get this right (read: in the supposed way) I would be grateful.

	atze

ps. my mouseDown: first checks if the user clicked at a point where two cells touch to be able to resize them.

_______________________________________________

Cocoa-dev mailing list (email@hidden)

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:
This email sent to email@hidden


References: 
 >editWithFrame:inView:editor:delegate:event: in mouseDown: (From: Alexander Spohr <email@hidden>)
 >Re: editWithFrame:inView:editor:delegate:event: in mouseDown: (From: "Kyle Sluder" <email@hidden>)

  • Prev by Date: Re: InputManagers in Leopard
  • Next by Date: Re: [MyClass class] returning superclass's class
  • Previous by thread: Re: editWithFrame:inView:editor:delegate:event: in mouseDown:
  • Next by thread: Changing Services HotKey at Runtime
  • Index(es):
    • Date
    • Thread