Sync CHClickListener with Camino. Not part of the default build.

This commit is contained in:
bryner%netscape.com 2003-03-18 23:19:39 +00:00
parent 0941f07bfd
commit e7316cf9cd

View File

@ -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:)];