i worry that my xcode vocabulary is insufficient here -
in Interface Builder,
i frequently would like to use the precise element-selection of the hierarchical element list, and then switch to jogging the position/size of the elements with the arrow keys.
the only way i know to do this is to carefully click on one of the drag-boxes revealed around an element when it's selected, which shifts keyboard focus from the element list into the visual layout. but this is difficult and error-prone because it's easy to accidentally move the element a bit, or the drag-box may be underneath another element, or you may have multiple elements selected, etc, so a hotkey of some sort would be ideal.
apologies for not having the right names for all the things here.
even the names would probably help me search.
A: obvious but i missed it - double-click the element in the hierarchy. it would be nice if there were a keyboard command to do this, but i'll settle for the double-click.
Related
I have two shape at same position, not same color, and when i click over them, i want to fire click event on both, not just the first.
These two shapes are in the same container.
I have tried getObjectsUnderPoint() under stage.on("mousemove"), but this function increase my FPS (60 to 32~, and inside there are just a console.log), So it's not a good solution.
I tried the bubble, the useCapture, but i think it isn't what i want.
I just want to fire click on all element behind my mouse.
If someone have a solution, please.
There are a few points here:
EaselJS objects sort of work like HTML DOM Elements. If an element has a mouse handler on it it will block objects in other hierarchies below it from receiving the event. This is just how it works. The main difference is that if you don't have mouse events, then they are just ignored (like if you set the pointerEvents on an HTML element to none to have the mouse ignore it).
Your idea with getObjectsUnderPoint is what I would have recommended. Running any hit-test logic on mousemove is going to be expensive (mousemove fires a LOT, which is why we give the ability to throttle the typical mouseover check if you enableMouseOver on the stage).
A few things to optimize it:
Ensure you are using mode=2 on your getObjectsUnderPoint, which will only check objects with mouse listeners. This greatly reduces the overhead in checking. [docs]
Instead of checking the stage on your own mousemove event, set a flag to check it on tick. This throttles it to your Ticker FPS at least. You could also set an interval to check it even less often. It can create a little bit of a visible lag, but you can probably find a nice balance.
Reduce what is checked. If you have a container with your clickable elements in it, you can only check that object for mouse interaction.
If your objects are the exact same, you can also just trigger the click manually on the second item.
obj1.on("click", function(event) {
obj2.dispatchEvent(event);
});
I hope those approaches provide you a solution. Let me know if you have follow-up questions.
Cheers,
Scenario
I have 3 panels which are to be shown depending upon the choice from combobox.
Each panel is designed in exact location, and all three are exactly overlapping each other and even may be partially. But their Top and Left properties are same.
Problem
As soon as I drag to position the panel, it becomes child of one of other two.
I have checked it through .parent.name
If I hide one panel say pnlRSB1 then the child of it the pnlRSB2 also vanishes.
Though I have solved the problem using recursive loop, but I want to know the other available options.
Is there a way that I may tell IDE, "hey don't make it child of underlying panel, its independent"?
B.T.W if someone wants the loop thing solution, I will provide that as well, but I hate recursion though I am living with it right now.
The solution is to not drag them. Just add all three Panels to the form somewhere. Drag one of them so that it's Location and Size are what you want and then set the other two to have he same values via the Properties window.
By the way, one Panel will only become a child of another if you drop it within the other's bounds. The parent will be whatever control is under the mouse pointer when you drop.
Also note that you can still easily access each Panel in the designer, even if they are in the same Location and have the same Size. You just have to change the z-order so that the one you want to access is at the front. There are a number of ways to do that.
Right-click on the Panel you can see and select Send to Back. Repeat until the Panel you want to access is in front.
Open the Properties window and select the Panel you want to access in the drop-down list at the top. This will draw a selection rectangle around the Panel even if the Panel itself is obscured. Right-click the selection rectangle and select Bring to Front.
Open the Document Outline window and either drag the Panel you want to access up above the others in the tree or select it and use the tool bar to move it up. The order of the child controls in the tree matches the z-order.
I'm using XAML Toolkit ImageButton control to be able to create normal and pressed states for a button. Code is:
<toolkit:ImageButton NormalStateImageSource="ms-appx:///Assets/1_off.png"
PressedStateImageSource="ms-appx:///Assets/1_on.png"
Width="500"
Height="200">
</toolkit:ImageButton>
Issue I'm facing is, say I have a shape which isn't rectangle or square. For example I have PNGs for star and arrow object. Is there a way to set their boundary corresponding to shape? If not, please advice the best approach to handle such scenarios.
There are two options I tried
When clicking using mouse or touch - you'd check the last position of the pointer before click and see if the image in your button has a non-transparent pixel at that position.
Pros:
It's simpler than option 2.
You get most precise information
Cons:
You can't tell if a button got clicked with mouse, touch, pen, keyboard or by narrator using automation, so you could end up filtering out keyboard clicks just because the mouse cursor is a bit off. You could possibly use some heuristics like how long ago was the pointer move or pointer down event before the click event, but it's a bit hacky and might be unreliable.
Generate a vector path for your image and put it in the button template as a Path element with Fill="Transparent", then mark any other non-transparent or hit testable template elements (buttons, borders with Background="Transparent", etc.) as IsHitTestVisible="false".
Pros:
Doesn't break any input methods
Can be quite precise
For some shapes like a circle - the Path.Data could be quite simple or you could even use something like an Ellipse element instead
Cons:
You need to generate the path somehow
A complex path might adversely affect performance
A better solution overall in most cases is to leave the hit-testable area rectangular. The reason is - an arbitrary shape is a finicky and unreliable hit test target so it makes clicking your button more difficult. Using the default rectangular border or at most - an ellipse shape is a lot simpler and more usable.
There is a tool button and a textctrl in the toolbar. I'm trying to expand the textctrl in the horizontal direction to fill all the remaining space.
wxSizer maybe a good choice but it seems not suitable with toolbar because I can't add tool button directly in a sizer.
There is no built in support for this, you will need to handle wxEVT_SIZE (either in the toolbar itself or in the frame containing it, as the size of the toolbar only changes when the size of the frame does), compute the available size (which is going to be tricky, there is no function to find this out neither so I expect you'd have to do some kind of binary search using wxToolBar::FindToolForPosition()) and resize your text control.
It would definitely be much simpler to put both the toolbar and the text in a sizer instead. But it's true that it wouldn't appear quite the same, so if you really want to have the text-inside-toolbar appearance, you would have to do the above. Good luck!
I have a UIMenuController which I have added a few extra items to. I would like the menu to be BELOW the text that I select, so I tried:
[UIMenuController sharedMenuController].arrowDirection = UIMenuControllerArrowDown;
That seemed to do nothing, and everything I try, won't put the menu below the text.
How can I do that?
According to the docs, arrowDirection sets the direction the arrow points; it has nothing to do with the location of the menu relative to its target area. It also looks like they don't give you any control over the positioning of the menu beyond setTargetRect:inView.
If you really want to put the menu below the text, you might be able to set a "fake" target area and change the arrow direction to point to the "real" area of interest.
However, there's probably a reason Apple does it this way. My guess? If you select some text with your finger, your hand is probably obscuring the part of the screen below the text... so it's not very helpful if the menu appears there. Going out of your way to break consistency with standard UI conventions isn't usually worth the effort.