Please Log-in or Register to get full access to the forums.


Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] close by left clicking outside tip
29th December, 10:04
Post: #1
[Solved] close by left clicking outside tip
So, I am making a right click menu with qtip2 and I want it to be hidden when you click anywhere outside the tip itself. I assume this needs to be done with the api and a special function but I cant really figure out the best way of doing it. Some help please? =)
Find all posts by this user
Quote this message in a reply
29th December, 17:48
Post: #2
RE: close by left clicking outside tip
Xtracted, sounds like you need a combination of right-click detection (http://craigsworks.com/projects/qtip2/tu...ightclick) and the unfocus event:
JS Code
$('.selector').qtip({
   content: $('#contextMenu'), // Use a pre-formatted element for the content
   position: {
      target: 'mouse', // Position it where the click was...
      adjust: { mouse: false } // ...but don't follow the mouse
   },
   show: 'mousedown', // Can't use click event for this, sorry!
   hide: 'unfocus',
   events: {
      show: function(api, event) {
         /* 
            event.originalEvent contains the event that caused the callback to be fired.
            event.originalEvent.button tells us which button was clicked e.g. 1= left, 2 = right;
         */
         return event.originalEvent.button === 2;
      }
   }
})
// Little snippet that stops the regular right-click menu from appearing
.bind('contextmenu', function(){ return false; });
Visit this user's website Find all posts by this user
Quote this message in a reply
30th December, 08:41 (This post was last modified: 30th December 08:42 by Xtracted.)
Post: #3
RE: close by left clicking outside tip
Perfect, the hide.unfocus was just what I was looking for! Thank you!

I am using the following to prevent the right click menu from appearing:
JS Code
}).bind("contextmenu", function (e) {
                e.preventDefault();
            });


Any comments on using that vs your:

JS Code
.bind('contextmenu', function(){ return false; });


(Except that your code is much prettier=) ?
Find all posts by this user
Quote this message in a reply
30th December, 19:39
Post: #4
RE: [Solved] close by left clicking outside tip
Well return false; actually calls preventDefault(); Check-out this article for more information: http://fuelyourcoding.com/jquery-events-...urn-false/
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  tooltip positioning left and centered of mouse criscap1985 0 139 20th June 08:12
Last Post: criscap1985
  qtip2 : Facing issue on all anchor tags, Tooltip jumps to top left of browser window baludharmaraj 0 259 18th February 11:04
Last Post: baludharmaraj
  destroy after hide after clicking a button DrLightman 1 381 1st February 15:38
Last Post: DrLightman
  Toolip won't close if mouse over the tooltip box Yoshikins 1 378 2nd November 10:30
Last Post: Yoshikins
  a few issues re: close buttons, nested qtips, etc. Goatvirus 0 727 30th January 19:11
Last Post: Goatvirus
  Don't want to close tooltip on button pressed within it. shantaram 0 770 31st October 13:06
Last Post: shantaram
  [Solved] how can i create custom close button? bondrayoon 7 1,558 25th August 09:28
Last Post: qemmoracuq
  [Solved] Tweak close button style on QTip usingqtip 5 6,255 1st April 11:22
Last Post: Craig
  [Solved] Kill Youtube Video on close in Chrome Wanahackaloogie 1 1,086 6th March 12:53
Last Post: Wanahackaloogie
  [Solved] Styling close button and <div> vs <a> ? bg17aw 14 3,092 29th November 13:53
Last Post: Craig



User(s) browsing this thread: 1 Guest(s)