How to find coordinates of mouse cursor in interface builder - xcode

I want to know exactly where I am placing my images programatically, and therefore need to know the coordinates of my storyboard.
Is there a way to view these from the interface builder in Xcode?

Your workspace dimension is 320X460 suppose you want to add a button programmatically first go into IB and place a button where you want it to be and then in the right side check the coordinates of button in show the size inspector and use those coordinates in your code this will give you a fair idea about where your button will go after you add it programmatically... hope this will help you

NO. Use your imagination. Programmatically added visual objects cannot be seen in IB.
Instead, you could place an object in IB, adjust it's position to the desired one, read it's frame, delete it from IB, and use it's frame values to programmatically add id.

Related

How to add an image by pressing a button in JavaFX

I want to be able to press a button and an image appear on the page.
Additionally, I want to be able to place the button with Y and X coordinates, not through layouts.
Would I need to use an image view?
Your question isn't very precise, so I hope I answer what you need.
To show an Image generally you need an ImageView, that is correct. For less common image formats you might need an external library.
To only show the image when the button is clicked, you have to first set the ImageView to not managed and not visible. Then when the button is clicked make it visible and managed and it will show.
About the absolute positioning of your button, you can override the layout children of any Parent object and set exact positions. Take a look at this question.

How to add a background image

I have a Image View on my storyboard, and when I am trying to use it as a background. No matter what I do, it always stays on top. How would I change it so that it would be a background image, I don't care weather I do it programmatically through swift or through another way.
In the Xcode Interface Builder, you can adjust which views are in the front by selecting the view and going to Editor -> Arrange -> Send to Front, Back, etc.
This can also be done programmatically using UIView methods like bringSubviewToFront:
By moving any of item up/down you can set their layer state. The first one will be on back then second will appear on the first one then.... last one will appear on top most.
I hope this will help you.
If you decide to do it programmatically, you can modify the zPosition property of the view:
myImageView.layer.zPosition = 1
Higher numbers are closer to your face, lower numbers are closer to the screen. So to set your image view as a background, make sure the other views have higher z-positions than it.

Drag and Drop functionality using testcomplete

I want to simulate a drag and drop functionality from one DevXtraGridcell to another DevXtraGridcell without using the coordinate system.
Can someone give me an idea how can I do it without the default record and play and without the source and destination cordinates.
The Drag action always uses coordinates, but you can calculate the coordinates on the fly instead of using hard-coded coordinates:
Explore your grid in TestComplete's Object Browser and find a method or property that returns cell coordinates.
According to this old blog post, it should be something like:
gridObj.MainView.ViewInfo.RowsInfo.GetInfoByHandle(Row).Cells.Item_2(Column).Bounds
Calculate the coordinates of the first and second cell. (Make sure that both cells are visible on the screen.)
Do the Drag from one first cell's coordiantes to the second cell's coordinates.
in my case i had to user the obj.MainView.get_ViewInfo property worked for one gridcontrol , the other is of card layout the link given doesnt work in my case though

An NSButton with two combined images (Cocoa OSX)

I want to make a type of popupbutton sort of like the action button on OSX. I need to make the button have two images makeup the representation of the button (the icon for the button and the downward facing disclosure triangle next to it). I was thinking maybe I could add the second image as a subview of the button but it seems that there should be a simpler way to do this. Any ideas?
Make an NSPopUpButton whose pullsDown is set to YES (Type of “Pull Down” in IB) and whose image is set to the image named NSImageNameActionTemplate (“NSActionTemplate” in IB).

Sizing a control to fit its container in Interface Builder

Let's say I have a split view, and I want to fill half of it with a table view (a fairly common use case, I would think). Is there any way to tell the table view to size itself to fit the split view or do I really have to size it manually?
I've done this, the way Jon Hess mentions first. Assuming you're using Interface Builder version 3:
Drag and resize your GUI (tableview from what I understand?) component to fit into the enclosing area the way you want it.
Click it to select it.
Press Command-Shift-I to open the inspector window for this GUI component. The inspector window should now actually show that you've selected a "Scroll View".
Click the "ruler" heading to be able to set the sizing. You'll see to the right an animated representation of how your GUI component will behave within its enclosing GUI component, and to the left another represenation of the same, without animation, but with four springs and two struts that you can turn on or off.
Turn all six things on, making them red.
Voilà :-)
It's generally easier to create the subviews first, then use the Layout/Embed Objects In/Split View menu item to create the split view around them.
As far as I know, doing it manually is the only way to go. However, if you turn on "snap to cocoa guidelines", the inner view will snap to the edges of the enclosing view as you drag towards them. This makes it easier than having to manually mouse the edges into place, or manually edit the sizes to match.
You can set all of the springs and struts of the table view to "on" in the size inspector and that will cause the table view to fill the split view. Alternatively, you can use the outline view in the main document window to place the tableview's enclosing scroll view directly into the splitview instead of in an intermediary custom view.

Resources