2011-12-14 51 views
2

设置桌面快捷方式的工具提示的最佳方式是什么?ExtJS 4桌面 - 如何设置桌面快捷方式工具提示

在我的getDesktopConfig()中,我创建了一个带有字段iconCls,模块,名称的快捷数据数组。下面是增加一个用户模块的快捷方式到阵列,然后设置阵列作为快捷方式的数据存储,其被用于创建桌面快捷方式的数据属性的示例:

Ext.define("MyDesktop.App", { 
extend: "Ext.ux.desktop.App", 

.... 

getDesktopConfig:   function() { 
    var b = this; 
    var a = b.callParent(); 

    ..... 

    shortcut_data.push({ 
      iconCls:  "users-shortcut", 
      module:   "users-module-window", 
      name:   "Users" 
     }); 

    ...... 

    return Ext.apply(a,{ 
     contextMenuItems: [{ 
      text:   "Dashboards", 
      handler:   b.onDashboards, 
      scope:   b 
     }], 
     shortcuts:   Ext.create("Ext.data.Store",{ 
      model:   "Ext.ux.desktop.ShortcutModel", 
      data:   shortcut_data 
     }), 
     wallpaper:   "/assets/MyApp_Wallpaper.jpg", 
     wallpaperStretch: false 
    }) 
}) 
}, 
..... 
+0

您错过了一条重要的信息。呈现快捷方式的组件是什么?如果这是你的快捷方式配置图标Cls:“用户快捷方式”, 模块:“用户模块窗口”, 名称:“用户” }它适用于什么? – dbrin 2011-12-15 00:11:46

+0

快捷方式已添加到桌面应用程序中。更新问题。 – 2011-12-15 00:23:24

回答

0

假设快捷方式通过产生一个按钮的派生我会用tooltip:'一些文本'配置为shortcut_data。

1

为您的工具提示添加一个字段到Ext.ux.desktop.ShortcutModel。在这里,我已经命名为qtipText。 Ext.ux.desktop.ShortcutModel秀现在这个样子:

Ext.define('Ext.ux.desktop.ShortcutModel', { 
    extend: 'Ext.data.Model', 
    fields: [ 
     { name: 'name' }, 
     { name: 'iconCls' }, 
     { name: 'module' }, 
     { name: 'qtipText' } 
    ] 
}); 

现在,当你定义的快捷方式,与附加价值这一领域的工具提示:

shortcut_data.push({ 
      iconCls:  "users-shortcut", 
      module:   "users-module-window", 
      name:   "Users", 
      qtipText:  "Open Users Window" 
     }); 

在Ext.ux的initComponent方法.desktop.Desktop,您会看到shortcutsView有一个用于itemclick事件的侦听器。只需添加另一个侦听itemmouseenter事件:

me.shortcutsView.on('itemmouseenter', me.onShortcutItemMouseEnter, me); 

定义处理程序如下:在第一次

onShortcutItemMouseEnter: function (dataView, record) { 
    if(!dataView.tip) 
     dataView.tip = Ext.create('Ext.tip.ToolTip', { 
      target: dataView.el, 
      delegate: dataView.itemSelector,        
      trackMouse: true, 
      html: record.get('qtipText') 
     }); 
    else 
     dataView.tip.update(record.get('qtipText')); 
}, 

dataView.tip犯规存在,我们创造了这个观点的工具提示。稍后,我们根据记录更新提示文本(对应于鼠标移过的快捷方式)。