Trigger Gallery OnFling without GUI Input - gallery

How can you trigger an onFling() without the user actually touching the device?
Actually my need is a little different than that. I have a horizontally-scrolling Gallery, and below that is a row of buttons. I want the user to be able to advance the gallery to the next View just by tapping a bottom-row button. Let's call this method next().
I envision calling the next() from the OnClickListener.

As it happens, there is a method available to Gallery. It is setSelected(int index).

Related

Woocommerce Order admin / edit page - how to trigger totals recalculation via JS upon order change?

Is there a way to trigger this recalculation upon change?
It can be done manually by clicking the button at the bottom of the order items rows, but can a change in the order be detected on the client side?
Thanks
There's always the .trigger() function:
$('button.calculate-action').trigger('click');
Unfortunately, this button pops a confirmation dialog that, to my knowledge, can't be forced to click 'Yes' or skipped in some way. The function called by clicking the Recalculate button is meta-boxes-order-items.recalculate(), which is tucked away in the meta-boxes-order.js file within a private variable. If possible we could just call that function directly, but alas, this isn't possible ( unless someone else knows... )
Perhaps clicking the Save button will help accomplish your goal?
$('button.save-action').trigger('click');

How can I make an action for a picture?

In my program, I want the users could touch a picture so that an action will be activated. However, the function IBAction cannot allow me to connect it with the picture. Is there any method that can help me to trigger a function when the users touch the picture? Thank you!
You can activate the User Interaction for that picture, and then detect taps on it and trigger the action based on them.
But the simplest solution would be to just put a button behind it, and connect the IBAction to that button. That's what we do in such cases.

Show alert if moving on without saving in Flex?

Functionnaly :
On one of my components of my application, I have an editing/lock system. When a user starts editing, he locks the file so other users cannot edit it.
Problem scenario : When the user activates "edition mode" and leaves screen, I would like to show a alert with two options : save changes, or discard changes.
There are different ways to exit screen :
There is a List on the left side containing other possible editabel data. A click changes the data in my component.
There is a menubar on top leading to other screens.
The edition component is embedded in a Tab navigator. When changing tabs, the alert has to show.
Closing browser.
Do I have to catch all of these events and plug at all those places?
Is there any kind of focusout mecanism?
The answer to the first question is: YES.
You need to watch all possible exit events that could harm the currently edited data.
Well, the problem is now how to manage this properly. Using an MVC framework you would trigger the appropriate commands from your components:
CHANGE_LIST_ITEM (new item)
CHANGE_TAB (new tab)
CHANGE_SCREEN (new screen)
Each command then checks if the currently edited tab has been saved or not. If not, it displays the Alert. Else, if there are no changes, it allows the list, the screen chooser and the tab bar to continue.
So your components (list, screens, tabs) need to implement some kind of rollback or preventDefault mechanism. Generally, changing their state must be allowed by a central validator (in MVC the command).
In the case of the list: I would suggest that the list is not selectable by mouse click but only programmatically. You set a listener on the list item click event. If the command allows setting of a new item it will notify the list. In MVC usually by sending an async message that gets received by the list's mediator. [[And even more correct: The command would set some model properties (e.g. currentListItem) and the model than sends an async message.]]
Edit: For the browser close event, you need to call a JavaScript expert.

QSystemTray problems

I am trying to use QSystemTrayIcon for my application and i am facing some problems.
It is the first time i use qt so i am not really used to it.
I followed this tutorial to make a system tray icon but i fail to customize it.
I want to have a button show/hide and not 3 show, hide, restore. These actions are really confusing for a newbie and i dont know what to do and what to connect.
I tried some things but with no luck.
Also when the system tray menu appears if you click somewhere else, the menu stays open.
Any way to solve this thing too?
If you want to remove one of the menu items, modify the createTrayIcon function so that it only adds the actions you need (and clean up the unused members once you get it to work). It's that simple.
If you want a single menu item or button to toggle between visible and hidden, you'll need to create a custom slot that calls show() or hide() (or setVisible(bool)) depending on whether the widget is hidden or not (use isVisible() for that for example). Then connect your action to that slot.
Read the Signals and Slots documentation and examples for information about how to create a new slot.

iOS Advanced Gestures: Getting Swipe Direction Vector

Looking through the documentation, it seems that the new advanced gestures API doesn't determine the direction of a swipe beyond the basic { left, right, up, down }.
I need the start point of the swipe and the direction.
Is there anyway to retrieve this other than coding my own advanced gesture library from scratch out the basic gestures?
And if this is my only option, could anyone point me to some open source code that does this?
Got it! Documentation is here, under 'Creating Custom Gesture Recognizers' at the bottom.
Basically the six gestures Apple provides all derive from UIGestureRecognizer, and you can make your own gesture recogniser in the same way.
then, inside your view's init, you hook up your recogniser. and just the act of hooking it up automatically reroutes incoming touch events.
Actually, the default behaviour is to make your recogniser an Observer of these events. Which means your view gets them as it used to, and in addition if your recogniser spots a gesture it will trigger your myCustomEventHandler method inside your view (you passed its selector when you hooked up your recogniser).
But sometimes you want to prevent the original touch events from reaching the view, and you can fiddle around in your recogniser to do that. so it's a bit misleading to think of it as an ' observer '.
There is one other scenario, where one gesture needs to eat another. Like you can't just send back a single click if your view is also primed to receive double clicks. You have to wait for the double-click recogniser to report failure. and if it is successful, you need to fail the single click -- obviously you don't want to send both back!

Resources