qTip 2: trigger hide before delayed show? - delay

I'm having an annoying little interaction issue with qTip 2. A button on my page has a tip attached to it, set to appear on mouseover after a 500ms delay and disappear immediately on mouseout.
When the button is clicked, the whole view changes and that particular button disappears, so I force the tip to hide immediately (otherwise, it hangs around until the user moves their mouse, even though the button that triggered it is no longer visible).
The problem is that the immediate hide event doesn't seem to cancel the delayed show event if it happens to occur first. In other words, if the user points at the button and clicks it in less than 500ms, the hide event triggers (doing nothing) and then the show event triggers at 500ms, causing the tooltip to display even thought the button is no longer there (and in the wrong position to boot, since it can't position itself correctly without the button being visible).
Is there a way when I trigger the hide event to tell it to just stop there and not perform any other events?

Not Tested
You can use the show event to check if the button visible , and if not than don't show it....
Something like this:
events: {
show: function(event, api) {
var target = event.originalEvent.target;
if($("#idOfButton").length === 0 ) {
event.preventDefault();
//or try this (commednt the above and uncomment the code below)
//clearTimeout(api.timers.custom);
}
}
}

I solved it like this (#Daniel, your answer was close so I'll upvote you too):
events: {
show: function(event, api) {
if ($("#mybutton").is(':hidden')) {
try { event.preventDefault(); } catch(e) {}
}
}
};
This is the method that qTip's documentation recommends.

Related

How to get the hand/controller that pressed a button

I would like to know, just by subscribing to the Interactable OnClick event, if I pressed the button with my left or right hand. Would that even be possible without passing this information along with the OnClick event?
The button has quite the logic to go through until it decides to accept a click request, so replicating all of that via global listener is not feasible.
Is it possible to get that information OnClick from somewhere else? Is it possible to query the potential click sources for who that was?
Without altering the Interactable class the only way I found was to query the FocusProvider for the active pointer, which must have been the one pressing the button (in my case):
https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/Input/Pointers.html
https://microsoft.github.io/MixedRealityToolkit-Unity/Documentation/Input/Controllers.html
Setup your controllers, take note of the axis name, in code you can do something like this in any GameObject's update loop:
if (Input.GetAxis("Axis1D.PrimaryHandButton") > 0.5f) {
// this axis (button) is pressed do something
}

Hide Wijdialog completely with out closing

I have multiple WijDialogs one above the other. Say flow comes like this:
Search Dialog -> Results Dialog -> Save Results Dialog
Consider control is currently in Results dialog which is above Search Dialog, when I move the Dialog I can still see the Search Dialog in the background.
But it is in the blur state because it lost its focus.
I want to make the background dialog completely hidden (make it invisible without closing the search dialog). It should be visible again on closing the Results Dialog .
I tried hiding the Div container of the Search Dialog, but still I can see the title bar.
I can hide the title bar completely by using $(".ui-dialog-titlebar").hide(); but I don’t know how to unhide or show the title bar.
In short, I want to make the background dialog invisible and visible with out losing the values I entered in it previously.
You can call the 'close' method of the first wijdialog to close it and then call its 'open' method in the close event of the second dialog. The data entered in the first dialog is retained until wijdialog is reinitialized. Please see the code below:
$('#dialog2').wijdialog({
autoOpen: false,
stack: true,
modal: true,
open: function () {
$('#dialog1').wijdialog('close');
},
close: function () {
$('#dialog1').wijdialog('open');
}
});

How to write an extension to close tabs on "back" attempt when there's no previous page?

I find myself more and more using the touchpad gesture of 3 fingers to the left or right in order to perform a "back" or "forward" in Google Chrome (on my Asus Zenbook, but I believe there's a similar gesture on Macs)
I found that when browsing, I open a tab to read something (Like a like from Twitter or Facebook) and when I'm done my instinct is to go "back" to get back to the previous tab I was browsing on. (I think I got that instinct from using Android a lot).
I figured that I need a Chrome extension that would close my current tab if I'm attempting to go "back" in a tab that doesn't have a previous page in its history.
I went over the Chrome events and various methods I can invoke and while there's a "forward_back" transition qualifier in the WebNavigation api, the onCommitted event doesn't fire when attempting to go "back" using the touchpad gesture or Alt+left keyboard shortcut.
Also, I couldn't find how I can access a current tab's history to see if the page I'm at doesn't have a previous one in the stack.
Ideas anyone?
function noHistory(tabId) {
// TODO
}
function getCurrentTabId() {
// TODO
}
function userHitBack() {
tabId = getCurrentTabId();
if (noHistory(tabId)) {
chrome.tabs.remove(tabId)
}
}
function attachEvent() {
// TODO attach userHitBack
}
attachEvent();
To catch the "back" event, you need to handle specific key pressed to call your "userHitBack" function. Something like this:
document.onkeydown = function() {
if (keyId == ...)
userHitBack()
}
You can use this to your advantage as you can bind any key to trigger the close of the tab.
To check the tab history length use this:
window.history.length
It is html5 historyAPI

jQuery or JS handling browsers back button

Any ideas how to intercept the browser back button via jQuery, so I can run my event function?
I don't need to use jQuery BBQ or jQuery Address, only prevent the default behaviour and run it later after some animate.
Thank you!
d
Have not tried but i guess this do what you want.
window.onbeforeunload = function () {
// stuff do do before the window is unloaded here.
}
with jQuery you could try the .unload() function
The unload event is sent to the window
element when the user navigates away
from the page. This could mean one of
many things. The user could have
clicked on a link to leave the page,
or typed in a new URL in the address
bar. The forward and back buttons will
trigger the event. Closing the browser
window will cause the event to be
triggered. Even a page reload will
first create an unload event.
In jQuery land:
$(window).unload( function () { /*code here*/ });
EDIT- There was a parentheses instead of a close bracket
EDIT - Removed Extra Semicolin

How to change the function called when I click in the close button on php-gtk?

I load a single instance of a window on php-gtk, I have a button named "Cancel" that hide(); the window, so when the window is needed again I just show();.
But when I click on the close button instead of the cancel button the window is destroyed. Even when I redirect the event (I'm not sure if i'm doing it right) it calls the first(just hide() function) and then the destroy method.
Any idea?
PD: I wouldn't want to destroy and recreate the windows because of php's crappy garbage collector and to be able to maintain previous data without having to refill the whole window(after all is supposed to be a desktop app).
Following the advice here: delete-event.
I changed my code to return TRUE:
function on_multipleCancelButton_activate()
{
global $GladeMultiple;
$MultipleWindow = $GladeMultiple->get_widget('multipleWindow');
$MultipleWindow->hide();
return TRUE;
}
On the GTK designer I linked the delete-event to this function.

Resources