Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trigger on Mouse Down #89

Closed
pushpinderbagga opened this issue Jan 8, 2013 · 12 comments
Closed

Trigger on Mouse Down #89

pushpinderbagga opened this issue Jan 8, 2013 · 12 comments

Comments

@pushpinderbagga
Copy link

Is there any way to trigger the dropdown on mousedown?

@ghost ghost assigned gfranko Jan 9, 2013
@gfranko
Copy link
Owner

gfranko commented Jan 9, 2013

Not currently, but I will add mousedown and mouseup events as default events when I release SelectBoxIt v2.7.0 (which should be released later tonight).

@pushpinderbagga
Copy link
Author

Ah thanks - waiting!

gfranko added a commit that referenced this issue Jan 9, 2013
gfranko added a commit that referenced this issue Jan 9, 2013
@gfranko
Copy link
Owner

gfranko commented Jan 9, 2013

So I decided to not increase the SelectBoxIt version number for this change, but mousedown and mouseup default events are now supported. Let me know if this works for you!

@pushpinderbagga
Copy link
Author

I tried to make it work but may be I cannot really get it through.

$(document).find("select").mousedown(function(e){
     $(this).data("selectBoxIt").open();
});

@gfranko
Copy link
Owner

gfranko commented Feb 25, 2013

Is there any reason you want to listen to the mousedown event to open the drop down when the click event already opens the drop down? The mousedown event is correctly triggered, but it conflicts with the click event handler for the open logic.

@who
Copy link

who commented Feb 25, 2013

@gfranko Actually, mousedown would be a nice addition, as some people (myself included) use a dragging motion to open and select list items.

The following works with Firefox native selects:

  1. Mousedown inside closed select. This opens the select menu list items.
  2. While still holding mousedown, hover over an , and mouseup.
  3. This selects the and collapses the list.

@gfranko
Copy link
Owner

gfranko commented Feb 25, 2013

@who Very interesting, I had never used this behavior. Do you think this should be added to the default behavior or just be left as an extra feature that can be done programmatically through the SelectBoxIt API (like the way @pushpinderbagga was doing it) ?

@who
Copy link

who commented Feb 25, 2013

@who Very interesting, I had never used this behavior. Do you think this should be added to the default behavior or just be left as an extra feature that can be done programmatically through the SelectBoxIt API (like the way @pushpinderbagga was doing it) ?

@gfranko I don't think it should be the default behavior, because exposing browser-specific idiosyncrasies might bring unintended consequences to existing implementations of SelectBoxIt. Perhaps a mode or setting should be added, and when it's on/enabled, would cause SelectBoxIt to have behavioral parity with regular selects, factoring in the context of the current browser. This setting could be called "useNativeBehavior", or something of that nature. Personally, I'd be happy to contribute to this feature, as I have become rather accustomed to the way FireFox handles selects and child options thereof.

Cheers,
A. Bird

@gfranko gfranko mentioned this issue Feb 25, 2013
8 tasks
@gfranko
Copy link
Owner

gfranko commented Feb 25, 2013

@who That would be great! I might be a bit tricky to implement, but I am here to help if you need anything.

@pushpinderbagga
Copy link
Author

Hello Frank,

I don't know if this is exclusive but I've been using Firefox since ever and it triggers the select box to open on mouse down so I felt the click open to be a little delayed. I checked in IE too - it opens on mouse down.

I just want it to open on mousedown - can we do it in some way?

Thanks
Bagga

@gfranko
Copy link
Owner

gfranko commented Feb 25, 2013

@pushpinderbagga I need to make a fix for it to work correctly, so I will update SelectBoxIt tonight. I'll let you know when you can start using it!

@gfranko
Copy link
Owner

gfranko commented Feb 28, 2013

@pushpinderbagga There are now two ways for you to trigger the drop down to open on mousedown:

  1. Using the nativeMousedown option: http://gregfranko.com/jquery.selectBoxIt.js/#NativeMousedownMode
  2. Using the customShowHideEvent, which removes the default open event handling and allows you to use custom logic, like you were doing above. You can set it like this:
$("select").selectBoxIt({ customShowHideEvent: true });

$("select").mousedown(function(e){
     $(this).data("selectBoxIt").open();
});

@gfranko gfranko closed this as completed Feb 28, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants