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

  • Home
  • SEARCH
  • 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 6829889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:33:12+00:00 2026-05-26T22:33:12+00:00

I have an app where I am creating two subviews of the main window,

  • 0

I have an app where I am creating two subviews of the main window, the subviews are of a class called Page and on each subview I am placing another subview of a class called Ad. I am dragging the Ad classes between the Page subviews. Initially I was just resetting the Ad class view’s frame, but what I really want to do is place it where the NSLeftMouseUp event occurs.

My process for doing this is to register all the Page subviews into an array as they are being created. I then made a subclass of NSWindow and assigned that class to my main window in IB. I pass the array of Page views to this class.

I think overwrite the sendEvent method, checking to see if the event is a NSLeftMouseDown, NSLeftMouseDragged or NSLeftMouseUp. The NSLeftMouseDown is to check and see if the subview clicked on is the deepest subview of the window hierarchy – window->Page class->Ad class, since I want to move ads and not pages. I loop through the array and then check the descendentOf method of the NSView (Ad) clicked to see if is a descendent of the NSView (Page) being enumerated. (Hope that made sense). I then pull it’s frame as well.

In NSLeftMouseDragged I change the cursor to resemble the ad being dragged.

In NSLeftMouseUp I check to see what view we are looking to move the ad to. What I can’t figure out is how to get the NSPoint for NSLeftMouseUp on that view, I can get it for the window but the x/y of that point will be way off for the receiving subview…how do I retrieve the NSPoint within the subview?

...
} else if ([e type] == NSLeftMouseUp) {

    //get which view we are going to drop the ad on
    landingView = [[self contentView] hitTest:[e locationInWindow]];

    /****ui question here for Mike:
     if the mouseup event is not on a page class, should the mouse remain the dragcursor image here or should 
     we change it back to the mouse icon and stop this process****/

    if ([[landingView className] isEqual:@"Page"]) { 

        //get ad rect
        float adX = thisAdFrame.origin.x + 10.0;
        float adY = thisAdFrame.origin.y + 20.0;

        //get nspoint of mouse up event
        NSPoint p = [e locationInWindow];

        [landingView addSubview:theSubView];
        [theSubView setFrame:NSMakeRect(p.x, p.y, thisAdFrame.size.width, thisAdFrame.size.height)];

    }

}
 ...
  • 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-26T22:33:13+00:00Added an answer on May 26, 2026 at 10:33 pm

    You might want to take a look at NSViews -convertPoint:fromView: and -convertPointFromBacking: Methods like these help to convert rectangles, points, etc into a different coordinate system.

    Specifying nil for fromView: will convert it from that view’s window. This code will apply to you:

    NSPoint eventLocation = [theSubView convertPoint:p fromView:nil];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating an iPad app, and I have two classes: NWRootViewController : UITableViewController and
I have two app domains, one parent creating the child domain. In the child
Our app would be creating dynamics forms for each users. We are considering two
Im creating an app using RoR to manage a basketball league. I have two
I'm creating an app that has the feature of adding two profiles/accounts. Each profile
I am creating an app, in which I have two small imageview (using have
We are creating an app with two main views: sView and sViewSettings. If the
For storing runtime data in my app I have a class with two static
Hi i'm creating an app which have shopping cart and payment done via paypal
I have a JavaScript widget which communicates with my Rails app by creating tags

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.