Detecting MouseUp or dragging session "willEnd" on NSDraggingSession in Cocoa OSX - swift

I've got an app where I'm allowing items to be dragged between NSTableViews. When the drag leaves the table, the table closes around the starting location of the removed cell.
When a user lets go of an item and the drag will be cancelled, I'd like to animate TableCellView's starting location opening back up at the same time as the dragItem is being returned to the list, so that it looks like the tableView is "opening back up" to receive the cancelled item.
I'm having trouble detecting the moment that the user releases the mouse and the event is cancelled. Both "draggingEnded" and "draggingSession( endedAt )" fire after the animation has completed. Does anyone have any idea how to capture the "mouseUp" moment of the cancellation?

Related

How to get Notify of Input Mouse Released when using GameplayCueNotify_Looping

I have been working on a project based on Lyra Framework and am currently trying to implement a Weapon Ability: Charge_Ability - like Halo energy pistol. Here is my issue:
In the GCNL, I am attempting to Bind the OnReleased Mouse Click Event to the OnLoopingStart. Doing so, I expect the OnReleased Mouse Click Event to be fired when the input broadcast its message so I can release my “Charge Ability Bolt Fx”.
However, when running debug printString, the OnLoopingStart is never called. Only the OnRecurring Event is fire.
How can I properly register the OnRelease Event from the GCNL to retrieve input released from mouse click?
Thanks!

BottomSheetDialogFragment- Close only on full swipe Kotlin Android

I have a BottomSheetDialogFragment to show list of items inside a fragment. Each list item got a click event mapped. The problem here is, most of the times click action turns into swipe down action and BottomSheetDialogFragment is getting closed. I have no custom events to monitor the events in my code.
dialog?.also {
it.findViewById<View>(R.id.design_bottom_sheet)?.let { bottomSheet ->
bottomSheet.layoutParams?.height = ViewGroup.LayoutParams.MATCH_PARENT
BottomSheetBehavior.from(bottomSheet).state = BottomSheetBehavior.STATE_EXPANDED
BottomSheetBehavior.from(bottomSheet).skipCollapsed = true
}
}
I have to prevent the close event of BottomSheetDialogFragment on click action which turns into swipe down action because of small extra movement added. This could happen and needs to handle since this application will be used by general public.
Can anyone suggest to find the swipe distance on BottomSheetDialogFragment. So that if the value is lower, the dialog will remain open. And if the value if high because of intentional swipe event, the dialog will get dismissed.

swift - how to prevent two touches at the same time

For example, I have 2 buttons Change email and Change password, and each of them call functions with Alamofire request, and responce data should reload both the UI and data scheme.
The point is that this PUT requests change not only servers's data, but generate new token and get updated user's profile.
And when pressing buttons at the same time, at the same moment touches begin and end, app crash after parsing requests.
I'm blocking another UI elements(like textfields), I was trying to block another button, but when press it together, it's not works.
So how can I prevent the same time touch? I'm not good at OperationQueue, maybe thats'the way? Is there an option to check if operation not first at the queue and kill it?
Set isExclusiveTouch of your UIButton to true in order to trigger only one button action in a specific time.
This code will get all the buttons contained in the view and set the exclusiveTouch to true:
self.view.subviewsRecursive()
.filter { $0 is UIButton }
.forEach { $0.isExclusiveTouch = true }
This problem with the UIResponder object is very usual. However, your problem description is not clear and your implementation seems not so good.
Here, to resolve this quick touch event problem:
Your solution is debouncing the action event of UIButton.
Debouncing also helps to prevent multiple executions when a user mistakenly pressed a button (or any UIResponder object) multiple times so quickly that even the UI was not blocked till then. Following article may guide you more regarding the same:
Debouncing to tackle repeating user action

How do I implement "Cancel" button inside the method building data source in ModelController.m for Page View Controller

I have a Page View Controller that's implemented in 3 files. One of them, the ModelController.m implements "generateData" method, which basically just builds and formats all the pages for this Page View Controller. Inside this method, the first thing I do is I create a Progress Bar popup with "Cancel" button. Then, inside the while() loop, I keep building the pages and at the same time, every 10th page, I update the progress bar for the user to see that the application is still generating the output.
Once the "generateData" method completes, i.e. builds all the pages (and there may be over 1,000 or even 10,000 pages depending on user input), it returns "self" to a method inside RootViewController.m, which in turn passes that generated data in "dataObject" to "viewWillAppear" in DataViewController.m, which finally displays pages in that object to the user.
It all works great, except the "Cancel" button. Because "generateData" method runs on the main thread, it blocks and the "Cancel" button becomes totally unresponsive. By "blocks" I of course mean it takes all CPU cycles, not allowing anyting else to execute, and it may take over a minute to generate 10,000 pages so I really want to allow the user to cancel the operation.
I tried to create a separate thread for the Progress Bar popup which contains Cancel button, but that won't work because all UI operations need to be performed on the application's main thread.
What almost seems to work, is when I put the "generateData" method on a separate thread and keep the Progress Bar on the main thread. This would work just fine, except that now "generateData" is put on another thread to execute in the background and returns immediately, hence returning empty "self" or rather empty "dataObject", causing a crash because there is nothing in that object yet to display.
So how can I check if the "generateData" thread is done, and "return self" ONLY when it's done? I can't really have some BOOL true/false variable and do it in a loop, because that loop on the main thread would be again blocking the "Cancel" button.
Or, alternatively, what is the correct way to implement the "Cancel" button on a lengthy method in iOS? Maybe I'm doing it all wrong, but for the life of me I can't find the right recipe for this.
Thank you in advance for the help, the code is rather extensive and that's why I didn't include any, but I hope my description gives you a good idea of what's going on. I can provide code if that would help.
The correct way to do this is to load the data asynchronously (on a background thread) and update the main (UI) thread to update the progress bar, etc... But you probably don't need a progress bar since you can probably load those pages faster than a user can flip them, so load 100 and let the user play while you continue to load the next 99,900... Except those may not be the exact numbers you should use....
If you continue to use the progress view and cancel button, then you would cancel the background thread when the user presses "Cancel", which would respond since your data generation is on a background thread...
Look into either Grand Central Dispatch or NSInvocationOperations
Here's a good tutorial by Ray Wenderlich to get you started.

ItemClickListener kicking off while ItemLongClickListener happens

The best way I can describe this is the following. I have a poster gallery that has a bunch of images. The selected poster gets highlighted as the user moves back and forth through the gallery. I have the following code set on the poster gallery:
Gallery posterGallery = (Gallery) context.findViewById(R.id.moviePosterGallery);
posterGallery.setAdapter(new MoviePosterImageGalleryAdapter(context, key,
item.getCategory()));
posterGallery.setOnItemSelectedListener(
new MoviePosterOnItemSelectedListener(bgLayout, context));
posterGallery.setOnItemClickListener(new MoviePosterOnItemClickListener());
posterGallery.setOnItemLongClickListener(new MoviePosterOnItemLongClickListener());
What seems to happen is if you press the Remote on the vizio costar, both the Click and Long click events are being fired if you hold down the OK button. As in my case a dialog pops up when a Long click is received, but also the poster launches the video related to that to start playing which is part of the ItemClickListener code..
When testing the same code on a Nexus 7 tablet, only the long click is fired, not both. Is there a way to handle the long click correctly on Google TV. I'm using a vizio costar with Google TV 3 if that helps.
Also, if you move the mouse pointer over the item, and then hold down the - key on the front of the remote, only the long click event is triggered. It just seems to be related to the OK and how long that held down.
I looked at the following similar issue:
onListItemClick and onItemLongClick Google TV
but I already have the onItemLongClick returning true when it handles the event.
There is a quirk with the Vizio remotes. The OK button is not mapped to the right keycode. The Vizio remote sends KEYCODE_ENTER when OK is pressed when in fact it should be sending KEYCODE_DPAD_CENTER. This is what is causing your issue I think. If you try using AbleRemote as the input device you should be able to see it working as expected. Now to solve your issue you may have to go to a keycode listener if a keyboard is present and detect the key events on the posterGallery to fire off short and long clicks.