mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 23:02:20 +00:00
Sync CHClickListener with Camino. Not part of the default build.
This commit is contained in:
parent
0941f07bfd
commit
e7316cf9cd
@ -52,7 +52,7 @@
|
||||
#include "nsIDOMNSHTMLElement.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIDOMHTMLOptionElement.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMHTMLOptionsCollection.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDocument.h"
|
||||
@ -123,8 +123,20 @@ CHClickListener::MouseDown(nsIDOMEvent* aEvent)
|
||||
return NS_OK;
|
||||
nsCOMPtr<nsIDOMHTMLSelectElement> sel(do_QueryInterface(target));
|
||||
if (sel) {
|
||||
PRInt32 size = 0;
|
||||
sel->GetSize(&size);
|
||||
PRBool multiple = PR_FALSE;
|
||||
sel->GetMultiple(&multiple);
|
||||
if(size > 1 || multiple)
|
||||
return NS_OK;
|
||||
|
||||
NSMenu* menu = [[NSMenu alloc] init]; // Retain the menu.
|
||||
nsCOMPtr<nsIDOMHTMLCollection> options;
|
||||
|
||||
// We'll set the disabled state as the options are created, so disable
|
||||
// auto-enabling via NSMenuValidation.
|
||||
[menu setAutoenablesItems: NO];
|
||||
|
||||
nsCOMPtr<nsIDOMHTMLOptionsCollection> options;
|
||||
sel->GetOptions(getter_AddRefs(options));
|
||||
PRUint32 count;
|
||||
options->GetLength(&count);
|
||||
@ -147,6 +159,10 @@ CHClickListener::MouseDown(nsIDOMEvent* aEvent)
|
||||
[menuItem setState: NSOnState];
|
||||
selIndex = i;
|
||||
}
|
||||
PRBool disabled;
|
||||
option->GetDisabled(&disabled);
|
||||
if (disabled)
|
||||
[menuItem setEnabled: NO];
|
||||
CHOptionSelector* optSelector = [[CHOptionSelector alloc] initWithSelect: sel];
|
||||
[menuItem setTarget: optSelector];
|
||||
[menuItem setAction: @selector(selectOption:)];
|
||||
|
Loading…
Reference in New Issue
Block a user