Thanks again.

Maybe I can post you what I have done and you can pinpoint what I am missing

IndicatorTextField.java

public class IndicatorTextField extends Composite implements HasText, 
HasKeyUpHandlers, HasBlurHandlers{
    
    public interface Binder extends UiBinder<Widget, IndicatorTextField> {
    }
    
    private static final Binder binder = GWT.create(Binder.class);
    
    public interface Style extends CssResource{
        String textStyling();
        String requiredInputLabel();
        String colorNotValidated();
        
        
    }
    
    @UiField Style style;
    @UiField Label label;
    @UiField TextBox textBox;
    
    
    public IndicatorTextField()
    {
        initWidget(binder.createAndBindUi(this));
    }
    
    

    @Override
    public String getText() {
        
        return label.getText();
    }

    @Override
    public void setText(String text) {
        label.setText(text);
        
    }


    @Override
    public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
        
        return textBox.addKeyUpHandler(handler);
        //return addDomHandler(handler, KeyUpEvent.getType());
    }
    @UiHandler("textBox")
    public void onKeyUp(KeyUpEvent event)
    {
        
        DomEvent.fireNativeEvent(event.getNativeEvent(), this);
    }
    
    @Override
    public HandlerRegistration addBlurHandler(BlurHandler handler) {
        
        return textBox.addBlurHandler(handler);
        //return addDomHandler(handler, BlurEvent.getType());
    }
    @UiHandler("textBox")
    public void onBlur(BlurEvent event)
    {
        DomEvent.fireNativeEvent(event.getNativeEvent(), this);
    }
}

This is the code in my main class where I am applying the textbox
@UiField IndicatorTextField txtFirstName;


@UiHandler("txtFirstName")
    void onKeyUp(KeyUpEvent event) 
    {
        validateFields();        
    }
    @UiHandler("txtFirstName")
    void onBlur(BlurEvent event)
    {
        validateFields();
    }
}
this should then fire validateFields() but still not. 

Arian


The class where I want to use the custom textbox

On Thursday, June 14, 2012 11:50:10 AM UTC+2, Jens wrote:
>
> Ooops, sorry my bad :) Somehow I assumed you want to fire events yourself 
> using fireEvent() inside a composite. If you want to hook up your 
> "internal" textbox then the easiest solution is to delegate to your 
> "internal" textbox, e.g.:
>
> public HandlerRegistration addKeyUpHandler(KeyUpHandler handler) {
>     return textbox.addKeyUpHandler(handler);
> }
>
> But in that case the KeyUpEvent.getSource() method will return the 
> "internal" textbox and not your IndicatorTextField because the TextBox 
> fired the event. You have to decide if you are fine with it. If you are 
> not, I think you have to catch the KeyUpEvent from the textbox internally 
> in your composite and then re-fire it with the corrected source.
>
> -- J.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/google-web-toolkit/-/v-nu-8rvAkoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to