Between windowDidMove and windowWillMove - cocoa

I've been trying with windowDidMove and windowWillMove (NSWindowDelegate) but I think I need something between these two...
Is there any other way to detect when I move my window in cocoa?
I mean - I want to trigger a function if I drag a window to the bottom of the screen, but I want this function to be run even if I didn't yet release the window?

The middle ground you are seeking is handling the mouse events yourself and implementing the window dragging. If you do this you determine how dragging works; so you can constrain the window to an area of the screen, trigger events when the window reaches a screen edge, etc.
You'll need to do some reading, you could start with Apple's Handling Mouse Events.
If you have problems once you've done the reading, written some code, etc. ask a new question, showing your code, and explain the problem you've hit. Somebody will probably help you out.
HTH

Related

Unity slider interaction with controller

So I have a laser pointer attached to my controller, shooting rays and triggering events whenever I press the tigger.
Tho it still has one or two buggs (Unity VR Controller UI Interaction), I have a more general question.
The UI needs some kind of slider. And I can't figure out how to make my pointer collide with the slider and behave in a slider-ish way. When I press my button, it currently ends up setting the slider to zero and not letting me drag it.
Thankful for any tipps on how to make them actually slide, since my ridgidbody-cube doesnt move and doesn't allow movement! Unitys documentation on e.g. the beginDragHandler isn't really helpful...
Cheers, Flo
If your enter/exit events already works, juste check the x (or the axis corresponding on your slider) of your "laser" every frame or so, and increase/decrease the value of the slider based on the delta between two check.
Hope it is clear, it should not be hard if you already have your events sets up !

Drawing on an image which is inside a QScrollArea?

If I subclass QLabel and I add a QLabel directly to my QDialog, it works fine. If I add this label inside a ScrollArea, the thing I’m drawing doesn’t show unless I resize the dialog itself. Yes, weird.
I’ve setup compilable example code that indicates what the problem is. What I am trying to do is to select an area of an image with my mouse, by drawing a rectangle on the corresponding area. The images my program is designed to work with can be very large, and thus, I need to have a scroll area so as the dialog to stay at a logical dimension, and not to fill the entire screen (or even multiple workspaces, if we are talking about a linux machine with multiple desktops).
Everything works fine, except that the drawing (selection-rectangle) isn’t visible unless the dialog is resized – manually. I think I have to update something while drawing, but I’m not sure what. Well, here’s the example code: http://paste.ubuntu.com/1151553/
Another issues that I don’t know how to solve (and I want your suggestions there) are (1) when the user is selecting an area, how to set it to automatically scroll when the user actually selects an area by pushing against to a wall of the scroll area (I guess I am understandable here). (2) is there a way to let the user select a rectangle and then, when he left-clicks on a position with holding down the [Shift] button, the bottom right edge of his previous selection to actually go through the point he clicks at?
The documentation indicates that you have to set a Layout somehow somewhere, but I'm not sure how to do this to my occassion.
Thanks in advance for any help.
about problem (1):
just use of Event. i think mouse Enter Event or Leave Event is good for that.
and to do that i think you can use a hidden rectangular that fill the whole of the screen.
and over write the mouse leave Event for that rectangular and tell in that function , to scroll the page.

handling issue with listbox in a pivot

I'm working on a app in which I used a listbox inside a pivot control just like the outlook app does. The problem is sometimes when I scroll the list, a swipe gesture is triggered and it goes to another pivot item. This is very annoying, and it seems doesn't happen to the outlook app. Am I doing something wrong? How do I fix it? Thanks a lot.
If you're just using the default controls in the default way then you're not doing anything wrong in your code.
You haven't said if you're getting this on the emualtor or on an actual device. I find I sometimes do this on the emulator if holding the mouse at a slight angle or on an actual device if holding that in a funny way (such as when lying down).
Whether you scroll the listbox or the pivot will depend on whether your finger (or mouse-if using the emulator on a non touch-screen PC) first moves vertically or horizontally after first touching the screen. In my experience the scenarios described above can lead to this not always working as expected but I've never seen an issue with this on a real device being held in one hand and scrolled using a thumb.

Windows: Mouse Down on Window Decoration

In almost any Windows application, I notice that holding the mouse button down in a non-client area causes the painting to stop. Why is this required?
For example, I have a Managed Direct 3D application which displays a spinning cube. If I place the pointer over the title bar and hold the mouse button down, the cube ceases to spin even though I have not coded any such condition into my loop.
Why is painting halted? What are the benefits? Most importantly, how can I work around this?
When you click on the title bar, there's a brief pause while the window manager tries to determine whether or not you're clicking or beginning a drag (moving the window). If you're still holding down the button, then it's a drag: the window manager sets up its own message loop and pumps messages until you release the mouse. Your window should still be able to process messages, because they'll still be dispatched, but if your animation depends on a custom message loop then you'll be stuck 'till the modal drag loop ends.
Work around it by triggering your animation in response to messages: a timer seems like a good choice to me.

How can I trigger Core Animation on an animator proxy during a call to resizeSubviewsWithOldSize?

I have some NSViews that I'm putting in one of two layouts depending on the size of my window.
I'm adjusting the layout when the relevant superview receives the resizeSubviewsWithOldSize method.
This works, but I'd like to animate the change. So naturally I tried calling the animator proxy when I set the new frames, but the animation won't run while the user is still dragging. If I release the mouse before the animation is scheduled to be done I can see the tail end of the animation, but nothing until then. I tried making sure kCATransactionDisableActions was set to NO, but that didn't help.
Is it possible to start a new animation and actually have it run during the resize?
I don't think you can do this easily because CA's animations are run via a timer and the timer won't fire during the runloop modes that are active while the user is dragging.
If you can control the runloop as the user is dragging, play around with the runloop modes. That'll make it work. I don't think you can change it on the CA side.
This really isn't an answer, but I would advise against animating anything while dragging to resize a window. The screen is already animating (from the window moving) - further animations are likely going to be visually confusing and extraneous.
CoreAnimation effects are best used to move from one known state to another - for example, when a preference window is resizing to accompany a new pane's contents, and you know both the old and new sizes, or when you are fading an object in or out (or both). Doing animation while the window is resizing is going to be visually confusing and make it harder for the user to focus on getting the size of the window where they want it to be.

Resources