2017-03-21 3 views
0

Wie zeige ich Tooltip eines Textfelds, wenn es im Fokus ist, nicht wenn die Maus über die Maus schwebt?Sencha Anzeige Tooltip eines Textfelds, wenn es im Fokus ist

Ich verwende TooltipConfig.

TextField email = getEditor().getEmail(); 
    ToolTipConfig toolTipConfig = new ToolTipConfig(); 
    toolTipConfig.setBodyText("TEXT BODY"); 
    toolTipConfig.setAnchor(Style.Side.LEFT); 
    toolTipConfig.setMouseOffsetY(0); 
    toolTipConfig.setMouseOffsetX(0); 

Antwort

0

Verwenden Sie extjs? Wenn ja, hier ist meine Antwort:

Sie müssen benutzerdefinierte QuickInfo erstellen, um das Standardmouseover-Ereignis zu deaktivieren.

Ext.define('nutnull.ToolTip', function() { 
 
    return { 
 
    extend: 'Ext.tip.ToolTip', 
 
    xtype: 'nutnull-tooltip', 
 
    // Set this as emptyFn so that it will not create mouse event to show the tooltip 
 
    setTarget: Ext.emptyFn 
 
    }; 
 
});

Dann können Sie das Textfeld überschreiben Tooltip während der Fokus Ereignis zu zeigen.

Ext.define('nutnull.override.Text', { 
 
    override: 'Ext.form.field.Text', 
 
    tip: null, 
 
    onFocus: function() { 
 
    // show tooltip if exist 
 
    if(this.tip) { 
 
     if(!this.tipCmp) { 
 
     this.tipCmp = Ext.create('nutnull.ToolTip', { 
 
      target: this.id, 
 
      html: this.tip 
 
     }); 
 
     } 
 
     // Get the position of the textfield instead of mouse position 
 
     this.tipCmp.targetXY = this.getPosition(); 
 
     // Adjust the position. 
 
     this.tipCmp.targetXY[0] += this.getWidth(); 
 
     this.tipCmp.targetXY[1] -= (this.getHeight()/2); 
 
     // Manually show the tooltip 
 
     this.tipCmp.show(); 
 
    } 
 
    this.callParent(arguments); 
 
    } 
 
});

In das Textfeld ein Element, fügen Sie einfach tip: 'Sample Description' Config.

{ 
 
    xtype: 'textfield', 
 
    fieldLabel: 'Name', 
 
    tip: 'Sample Description' 
 
}

+0

Ich benutze gxt, aber vielen Dank für die Antwort :) Ich löste dieses Problem :) – firstontheworld

0

aufgelöst ich dieses Problem. Ich habe ein neues Tooltip-Objekt und eine verpackte Tooltip-Konfiguration in dieses Objekt eingefügt.

TextField email = getEditor().getEmail(); 
ToolTipConfig toolTipConfig = new ToolTipConfig(); 
toolTipConfig.setBodyText("TEXT BODY"); 
toolTipConfig.setAnchor(Style.Side.LEFT); 
toolTipConfig.setMouseOffsetY(0); 
toolTipConfig.setMouseOffsetX(0); 
Tooltip tooltip = new ToolTip(email,toolTipConfig); 
tooltip.show(); 
Verwandte Themen