зеркало из https://github.com/mozilla/gecko-dev.git
Adding in access key support. More checkins on the way
This commit is contained in:
Родитель
53726b6464
Коммит
868b065c7c
|
@ -97,6 +97,7 @@ nsMenu::nsMenu() : nsIMenu()
|
|||
mDOMElement = nsnull;
|
||||
mWebShell = nsnull;
|
||||
mConstructed = false;
|
||||
mLabel = " ";
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
|
@ -172,7 +173,21 @@ NS_METHOD nsMenu::GetLabel(nsString &aText)
|
|||
NS_METHOD nsMenu::SetLabel(const nsString &aText)
|
||||
|
||||
{
|
||||
mLabel = aText;
|
||||
mLabel = aText;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::GetAccessKey(nsString &aText)
|
||||
{
|
||||
aText = mAccessKey;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
NS_METHOD nsMenu::SetAccessKey(const nsString &aText)
|
||||
{
|
||||
mAccessKey = aText;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -60,6 +60,8 @@ public:
|
|||
NS_IMETHOD GetParent(nsISupports *&aParent);
|
||||
NS_IMETHOD GetLabel(nsString &aText);
|
||||
NS_IMETHOD SetLabel(const nsString &aText);
|
||||
NS_IMETHOD GetAccessKey(nsString &aText);
|
||||
NS_IMETHOD SetAccessKey(const nsString &aText);
|
||||
|
||||
NS_IMETHOD AddItem(nsISupports * aItem);
|
||||
|
||||
|
@ -106,6 +108,7 @@ protected:
|
|||
nsIDOMNode * menuNode);
|
||||
|
||||
nsString mLabel;
|
||||
nsString mAccessKey;
|
||||
HMENU mMenu;
|
||||
|
||||
nsIMenuBar * mMenuBarParent;
|
||||
|
|
|
@ -147,9 +147,11 @@ nsEventStatus nsMenuBar::MenuConstruct(
|
|||
if (menuElement) {
|
||||
nsString menuNodeType;
|
||||
nsString menuName;
|
||||
nsString menuAccessKey = " ";
|
||||
menuElement->GetNodeName(menuNodeType);
|
||||
if (menuNodeType.Equals("menu")) {
|
||||
menuElement->GetAttribute(nsAutoString("name"), menuName);
|
||||
menuElement->GetAttribute(nsAutoString("accesskey"), menuAccessKey);
|
||||
// Don't create the whole menu yet, just add in the top level names
|
||||
|
||||
// Create nsMenu
|
||||
|
@ -169,6 +171,8 @@ nsEventStatus nsMenuBar::MenuConstruct(
|
|||
|
||||
// Set nsMenu Name
|
||||
pnsMenu->SetLabel(menuName);
|
||||
// Set the access key
|
||||
pnsMenu->SetAccessKey(menuAccessKey);
|
||||
// Make nsMenu a child of nsMenuBar. nsMenuBar takes ownership
|
||||
pnsMenuBar->AddMenu(pnsMenu);
|
||||
|
||||
|
@ -287,6 +291,19 @@ NS_METHOD nsMenuBar::InsertMenuAt(const PRUint32 aPos, nsIMenu *& aMenu)
|
|||
{
|
||||
nsString name;
|
||||
aMenu->GetLabel(name);
|
||||
|
||||
//get access key
|
||||
nsString accessKey = " ";
|
||||
aMenu->GetAccessKey(accessKey);
|
||||
if(accessKey != " "){
|
||||
//munge acess key into name
|
||||
PRInt32 offset = name.Find(accessKey);
|
||||
if(offset != -1)
|
||||
name.Insert("&", offset);
|
||||
}
|
||||
|
||||
//strcat the accelerator to the end of the name
|
||||
|
||||
char * nameStr = GetACPString(name);
|
||||
|
||||
mItems->InsertElementAt(aMenu, (PRInt32)aPos);
|
||||
|
|
Загрузка…
Ссылка в новой задаче