ext.ux.ImageButton的用法(图片按钮)
2009-10-27 14:31
351 查看
ext中imageButton的定义及使用
var simple; function createFormPanel(){
Ext.namespace('Ext.ux'); Ext.ux.ImageButton = function(cfg) { Ext.ux.ImageButton.superclass.constructor.call(this, cfg); }; Ext.extend(Ext.ux.ImageButton, Ext.Button, { onRender : function(ct, position) { this.disabledImgPath = this.disabledImgPath || this.imgPath; var tplHTML = '<div><img src="{imgPath}" mce_src="{imgPath}" border="0" width="{imgWidth}" height="{imgHeight}" alt="{tooltip}" style="cursor: {cursor};" mce_style="cursor: {cursor};"/> {imgText:htmlEncode}<br/><br/></div>'; var tpl = new Ext.Template(tplHTML); var btn, targs = { imgPath : this.disabled ? this.disabledImgPath : this.imgPath, imgWidth : this.imgWidth || "", imgHeight : this.imgHeight || "", imgText : this.text || "", cursor : this.disabled ? "default" : "pointer", tooltip : this.tooltip || "" }; btn = tpl.append(ct, targs, true); btn.on("click", this.onClick, this); if (this.cls) { btn.addClass(this.cls); } this.el = btn; if (this.hidden) { this.hide(); } }, disable : function(newImgPath) { var replaceImgPath = newImgPath || this.disabledImgPath; if (replaceImgPath) this.el.dom.firstChild.src = replaceImgPath; this.disabled = true; }, enable : function(newImgPath) { var replaceImgPath = newImgPath || this.imgPath; if (replaceImgPath) this.el.dom.firstChild.src = replaceImgPath; this.disabled = false; } }); Ext.reg('imagebutton', Ext.ux.ImageButton);
var myImageButton=new Ext.ux.ImageButton({ imgPath : '../images/dl_pic.jpg', imgWidth : 77, imgHeight : 64, tooltip : 'test', handler : loginGo });
var myImageButton=new Ext.ux.ImageButton({ imgPath : '../images/dl_pic.jpg', imgWidth : 77, imgHeight : 64, tooltip : 'test', handler : loginGo//loginGo是方法 });
var txtUserName = new Ext.form.TextField({ fieldLabel : '<bean:message key="username"/>', id : 'userName', name : 'userName', listenets : { "render" : function addUserName(obj){ obj.focus(); } } }) var txtPassWord=new Ext.form.TextField({ id : 'passWord', fieldLabel : '<bean:message key="password"/>', name : 'passWord', inputType : 'password' });
simple = new Ext.FormPanel({ frame : true, id : 'login', region : 'center', forceFit : true, border : true, width : 360, height : 70, renderTo : 'loginForm', items : [{ layout:'column', border:false, items : [ {columnWidth :.62, border : true, layout : 'form', labelWidth : 40, items : [txtUserName,txtPassWord]} },{ columnWidth :.38, border : true, layout : 'form', labelWidth : 40, items : [myImageButton] }] }], keys:[{ key:Ext.EventObject.ENTER, fn:loginGo, scope:this }] });
}
function loginGo(){ if(!checkUserInfo(this)){ return false; } document.forms[0].action='<%=basePath%>/login.do; document.forms[0].submit(); }
Ext.onReady(function(){ Ext.form.Field.prototype.msgTarget = 'side'; createFormPanel(); <% if(request.getAttribute("userName")!=null){ %> var userName='<%=request.getAttribute("userName")%>'; simple.findById("userName").setValue(userName); <%}%> simple.findById("userName").focus(); });
相关文章推荐
- ImageButton点击按钮改变图片
- Android——图片视图(ImageView)、状态开关按钮(ToggleButton)、时钟、图片透明度、滚动和时间选择器
- Android ImageButton Example 图片按钮
- 在ImageView上添加Button并为图片做填充和为Button按钮设置透明度
- 一看就会Android之按钮Button和图片按钮ImageButton的用法
- ASP.NET中ImageButton图片按钮控件的使用
- andoid点击按钮(ImageButton)时改变按钮的背景图片 SelectorDemo
- 会闪光的按钮Button和图片ImageView,ProgressBar进度条颜色闪动
- ASP.NET中ImageButton图片按钮控件的使用
- Android ImageButton单击切换按钮图片效果
- Android 笔记:ImageButton单击切换按钮图片效果的实现(转)
- Android ImageButton Example 图片按钮
- Asp.net ImageButton 根据编辑表单类型显示不同按钮图片
- Android——滚动视图(ScrollView)图片视图(ImageView)、状态开关按钮(ToggleButton)、时钟
- Uinty的uGUI学习(02):Image(图片)、button(按钮)
- iOS开发-button setImage按钮不显示图片问题
- 拉伸按钮背景图片:stretchableImageWithLeftCapWidth:
- Flex AIR:用 mx:Image 实现的动态图片按钮
- Android中ImageButton自定义按钮的按下效果的代码实现方法,附网上2种经典解决方法
- 开关按钮(ToggleButton)与开关(Switch)的功能与用法