Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3849222
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:49:18+00:00 2026-05-19T16:49:18+00:00

Dear All, I am fighting with NSOutline View to perform drag-n-drop within the table

  • 0

Dear All,
I am fighting with NSOutline View to perform drag-n-drop within the table since last 2-3 day but couldn’t get what i am doing wrong,
This is what i have done so far,

Requirement,
1 — I want to have a transparent or with some background image NSoutlineview in my view, to do that, i need to overwrite drawRect method of NSOutlineView, this is what i have done

in header file

@interface MyCustomOutlineView:NSOutlineView{
NSImage *pBackgroundImage;

}

- setBackgroundImage:(NSImage *)pImage;

In source file, i just overwrite drawRect and some other stuffs to draw the background image or to make it transparent and this is working fine,

Now in my view, i have declared the NSOutlineView object like that,

/*
* My Custom view will have capability to draw the gradient and other effects
*/

@interface OutlineParentView:MyCustomView<NSOutlineDataSource>{
   MyCustomOutlineView *pOutlineView;
}

@property(nonatomic,retain)MyCustomOutlineView *pOutlineView;

In source file, implemented following method ,
This method will be called from the initWIthFrame

#define OutlineViewPrivateDataType "MyOutlinePrivateData"
-(void)InitOutlineView{
    NSRect          scrollFrame = [self bounds];
    NSScrollView*   scrollView  = [[[NSScrollView alloc] initWithFrame:scrollFrame] autorelease];
    [scrollView setBorderType:NSNoBorder];
    [scrollView setHasVerticalScroller:YES];
    [scrollView setHasHorizontalScroller:NO];
    [scrollView setAutohidesScrollers:YES];
    [scrollView setDrawsBackground: NO];
    NSRect          clipViewBounds  = [[scrollView contentView] bounds];
    pOutlineView       = [[[CommUICustomOutlineView alloc] initWithFrame:clipViewBounds] autorelease];
    NSTableColumn*  firstColumn     = [[[NSTableColumn alloc] initWithIdentifier:@"firstColumn"] autorelease];
    ImageTextCell *pCell = [[ImageTextCell alloc]init];
    [firstColumn setDataCell:pCell];
    [pCell setDataDelegate:self];
    [firstColumn setWidth:25];
    [pOutlineView  addTableColumn:firstColumn];
    [pOutlineView setRowHeight:30];
    [pOutlineView setDataSource:self];

    /* setData delegate implemented in the MyOutlineView to handle some of event in this  
       interface if i don't write this, then i can't handle the menu event on the 
       Outlineview  
     */
    [pOutlineView setDataDelegate:self];

    **/* On this line i am getting one warning, saying OutlineParentView doesn't implement    
       NSOutlineView delegate protocol */**
    [pOutlineView setDelegate:self];
    [scrollView setDocumentView:pOutlineView];
    /* I don't want group row to be highlighted */
    [pOutlineView setSelectionHighlightStyle:NSTableViewSelectionHighlightStyleSourceList];
    [pOutlineView registerForDraggedTypes:
         [NSArray arrayWithObjects:OutlineViewPrivateDataType,nil]];

    [pOutlineView setDraggingSourceOperationMask:NSDragOperationEvery forLocal:YES];
    [scrollView setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
        [self addSubview:scrollView];
    [self setAutoresizesSubviews:YES];
    [self log:@"Outline view created "];

}

Other Important method related to Drag-n-Drop implemented as below

- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteb oard:(NSPasteboard *)pboard{
    [self log:@"write Items"];
    NSData *data = [NSKeyedArchiver archivedDataWithRootObject:items];
    [pboard declareTypes:[NSArray arrayWithObject:OutlineViewPrivateDataType] 
    owner:self];
    [pboard setData:data forType:OutlineViewPrivateDataType];
    return YES;
}

    - (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id < NSDraggingInfo >)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
    {
        NSLog(@"validate Drop");
        return NSDragOperationEvery;
    }
    - (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id < NSDraggingInfo >)info item:(id)item childIndex:(NSInteger)index{
        [self log:@"inside accept drop for NSView "];
        return YES;
    }

I checked apple DragnDrop Sample code, but couldn’t get what i am doing wrong,
i believe, some problem with the

[pOutlineView setDelegate:self]

Function, but how to solve that, that i don’t know,
I upgraded recently from MyTableView to MyOutlineView, recently i was able to perform Drag-nDrop on the Custom Table view,
Remaining things are working fine, like DataSource etc…

Thanks in Advance
Kind Regards
Rohan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T16:49:18+00:00Added an answer on May 19, 2026 at 4:49 pm

    i was setting ColumnWidth so drag-n-drop working for the width which has been set, not on the full row my mistake 🙁

     [firstColumn setWidth:25];
    

    Removing this line working fine

    But guys facing some other problem
    Regarding NSoutlineView and WriteItem | Drag-and-Drop Problem

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Dear all from the below mentioned table im picking imgurl with this query but
Dear All, please help me since I'm newbie in SQL Server. I have a
dear all.. i'm new to ajax timer, since someone tell me to use it
dear all..i have a table it looks like: Name version DDX 01 DTX 05
dear all. i'm familiar with MySQL but not in Firebird. i try to search
dear all, i tried the code below to make the export to excel, but
<div style='width: 240px; height:530px; overflow:scroll;'> <table> bla.. bla.. </table> </div> Dear all, I want
Dear all, I have a question about Facebook Page: ( NOT user profile page,
Dear all,Now i have this question in my java program,I think it should be
Dear all, I have a select query that currently produces the following results: DoctorName

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.