Finder item in some point - objective-c

I am clicking with the right mouse button in some Finder's window. I am getting the location of the click (its CGPoint). How can I tell what item is in that point ?

You can get selected item using below apple script
tell application "Finder"
selection
end tell

You would have to do it manually if Parag Bafna's suggestion doesn't work for you. Basically a Finder item has a position property. However the coordinates you get back are in the window coordinates. I'm assuming that your CGPoint is in global coordinates so you'll have to convert the window coordinates to global coordinates. You can do that easily enough because the window has it's own coordinates so you can figure out the global coordinates of a Finder item.
So it's doable with a little work using the Finder items' position property.
tell application "Finder"
tell window 1
set theItems to items
set oneItem to item 1 of theItems
return position of oneItem
end tell
end tell

Related

ContextMenuStrip Location Point

How to open the ContextMenuStrip programmatically at the cursor on right mouse button down/clicked over PictureBox?
I need to open ContextMenuStrip only in some areas of an Image (Schedule) in a PictureBox, so I disconnected the PictureBox.ContextMenuStrip property from the ContextMenuStrip1 and I'm firing it manually. That means I need to provide a point, which appears to be surprisingly challanging.
My question is similar to "How to get location of ContextMenuStrip", but I need to account for both vertical and horizontal scrolling, which it doesn't (unless I messed something).
So when I'm trying something like this (in PictureBoxPlan.MouseDown):
Dim rpt As Point = Me.PointToClient(PictureBoxPlan.Parent.PointToScreen(e.Location))
...it has a fundamental flaw, because the e.Location is in context of Image, regardless how it is scrolled within the PictureBox. I tried to Form.MouseDown event, but it's not fired, when [right] clicked on a PictureBox.
Just for confirmation, I still need the point in PictureBox context to analyze whether the ContextMenuStrip should be shown or not and to lookup associated ID.
I am now trying to use some constants (may not work if windows "font size" is set to other than 100%) together with scroll bars values, which is not optimal at all.
OK, I found what is breaking the logic in the ContextMenuStrip.Show(Point) documentation:
Show(Point)
Positions the `ToolStripDropDown` relative to the specified screen location.
So the ContextMenuStrip, to my surprise, takes the screen coordinates, not the Form ones. I then just removed PointToClient and everything works as a charm, regardless of window position on the screen or scrollbars position of the Image container:
Dim rpt As Point = PictureBoxPlan.PointToScreen(New Point(e.Location.X, e.Location.Y))
No need to take into account PanelPlan.VerticalScroll.Value or PanelPlan.HorizontalScroll.Value.

Is it possible to modify the selection rect for an IKImageBrowserCell?

We are using a subclass of IKImageBrowserView that contains a subclass of IKImageBrowserCell as the cells
The problem we're facing is when an image has a tall aspect ratio:
That first item can only be selected when you -mouseDown: directly on the skinny image.
I want to make it so that the item will be selected if you click anywhere in the imageContainerFrame
In IKImageBrowserView, there is a method: -indexOfItemAtPoint.
This returns NSNotFound when I click within the cell container frame, but returns the correct index when I click on the skinny image.
I don't think I can override this method to return the appropriate index when the mouse goes down in the cell-- but from what it looks like, that is my only option.
Does anybody know of any ways I could tackle this?

App Inventor: Making one button change more than one variable

This is about App Inventor 2, i had a button which could change depending on what image sprite had been activated. However, i deleted this button accidentally and lost all of the blocks assigned to it. I cannot remember how to do it. Could someone please tell me how I create a button that can change the value of more than one variable depending on what image sprite has been activated?
You can set specific counter for specific sprite. Just set the counter when the sprite is touched. Then, when the button is clicked, you need to use if and else function to check for what sprite is touched. Below is an example of code, yet it is not complete:

Detect mouse over nsbezierpath

I'm a starting developer and I have this single window Mac application with a custom view inside. Inside that custom ceix I have defined multiple nsbezierpath.
Each nsbezierpath represents a region of my map so they are not rectangular at all.
What I would like to have is a way to detect when my mouse enter a nsbezierpath so that I could display the name of the region over which the mouse is hovering.
I can't seem to find where to start, any ideas ?
Thanks for looking into my problem
Set up a tracking area to detect mouse movement (NSTrackingArea). Be sure that the mouse location is in the view coordinate system, then use the location in a call to containsPoint: on each bezier path to determine which ones the mouse is over.

opening presentOptionsMenuFromRect:inView:animated: at a specific orientation

I am trying to use presentOptionsMenuFromRect:inView:animated: to open the Options Menu at a specific orientation. I know how to select the location the anchor points to, but is there a way I can control the orientation of the menu itself - to decide whether I want it to open above/below/left/right from the anchor position?
I couldn't find any reference to it, and I tried to supply the Rect parameter with size, just to see what happens - it didn't affect the menu at all.
Is there a way to control the options menu?