Am 19.11.2008 um 19:27 schrieb Kyle Sluder:

On Wed, Nov 19, 2008 at 7:51 AM, Alexander Spohr <[EMAIL PROTECTED]> 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 (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to