2016-02-03 149 views
0
var oToolbar = new sap.ui.commons.Toolbar({standalone: false, design: sap.ui.commons.ToolbarDesign.Standard}).addStyleClass("uiActionToolbar"), 

oToolbar.addItem(new sap.ui.commons.Button({text: "Key equipment(LIVE)", styled: false, lite: true, icon:"sap-icon://email", 
         //pressed:true, 
         //style: sap.ui.commons.ButtonStyle.Emph, 
         press:function(oEvent){ 
           oAppContainer.addPage(oPage1); 
           oAppContainer.to(globalId+"page1"); 
         } 
        })), 
oToolbar.addItem(new sap.ui.commons.Button({text: "Key equipment", styled: false, lite: true, icon:"sap-icon://email", 
         //pressed: false, 
         //style: sap.ui.commons.ButtonStyle.Emph, 
         press:function(oEvent){ 
           oAppContainer.addPage(oPage2); 
           oAppContainer.to(globalId+"page1"); 
         }})) 

簡單的按鈕按上面的代碼中有一個工具欄,我想告訴他們強調了2個按鈕選擇的時候我已經添加了對:突出顯示openui5

//pressed:true, 
//style: sap.ui.commons.ButtonStyle.Emph, 

但他們都不似乎工作。

回答

1

只需設置styled屬性truelite財產falsepress事件發生後,在所有的刪除和更新按鈕的風格:

oToolbar.addItem(new sap.ui.commons.Button({ 
    text: "Key equipment(LIVE)", 
    styled: true, 
    lite: false, 
    icon:"sap-icon://email", 
    press:function(oEvent){ 
     if(this.getStyle() === "Default"){ 
      this.setStyle("Emph"); 
     }else{ 
      this.setStyle("Default"); 
     } 
     oAppContainer.addPage(oPage1); 
     oAppContainer.to(globalId+"page1"); 
    } 
})); 

Here就是一個例子。

+0

'style:true,lite:false'實際上是默認的..所以我建議完全刪除這些設置以獲得更簡潔的代碼。 – Marc

+0

@Marc可能由於某種未知的原因,主題創始人需要他們:-D但是你是對的,這就是爲什麼我建議選擇刪除他們。 – keshet

+0

Sry,是盲人。只是看着代碼,而不是文字;) – Marc