protected void createScrollers() { if (el().select(".x-menu-scroller").getLength() == 0) { Listener<ClickRepeaterEvent> listener = new Listener<ClickRepeaterEvent>() { public void handleEvent(ClickRepeaterEvent be) { onScroll(be); } }; El scroller; scroller = new El(DOM.createDiv()); scroller.addStyleName("x-menu-scroller", "x-menu-scroller-top"); scroller.setInnerHtml(" "); ClickRepeater cr = new ClickRepeater(scroller); cr.doAttach(); cr.addListener(Events.OnClick, listener); addAttachable(cr); el().insertFirst(scroller.dom); scroller = new El(DOM.createDiv()); scroller.addStyleName("x-menu-scroller", "x-menu-scroller-bottom"); scroller.setInnerHtml(" "); cr = new ClickRepeater(scroller); cr.doAttach(); cr.addListener(Events.OnClick, listener); addAttachable(cr); el().appendChild(scroller.dom); } }
@Override protected void onRender(Element target, int index) { super.onRender(target, index); allowed = new ArrayList<Character>(); for (int i = 0; i < baseChars.length(); i++) { allowed.add(baseChars.charAt(i)); } if (allowNegative) { allowed.add('-'); } if (allowDecimals) { for (int i = 0; i < decimalSeparator.length(); i++) { allowed.add(decimalSeparator.charAt(i)); } } Listener<ClickRepeaterEvent> listener = new Listener<ClickRepeaterEvent>() { public void handleEvent(ClickRepeaterEvent be) { if (SpinnerField.this.isEnabled()) { if (!hasFocus) { focus(); } if (be.getType() == Events.OnClick) { if (be.getEl() == trigger) { onTriggerClick(null); } else if (be.getEl() == twinTrigger) { onTwinTriggerClick(null); } } else if (be.getType() == Events.OnMouseDown) { if (be.getEl() == trigger) { trigger.addStyleName("x-form-spinner-clickup"); } else if (be.getEl() == twinTrigger) { twinTrigger.addStyleName("x-form-spinner-clickdown"); } } else if (be.getType() == Events.OnMouseUp) { if (be.getEl() == trigger) { trigger.removeStyleName("x-form-spinner-clickup"); } else if (be.getEl() == twinTrigger) { twinTrigger.removeStyleName("x-form-spinner-clickdown"); } } } } }; ClickRepeater cr = new ClickRepeater(trigger); cr.addListener(Events.OnClick, listener); cr.addListener(Events.OnMouseDown, listener); cr.addListener(Events.OnMouseUp, listener); addAttachable(cr); cr = new ClickRepeater(twinTrigger); cr.addListener(Events.OnClick, listener); cr.addListener(Events.OnMouseDown, listener); cr.addListener(Events.OnMouseUp, listener); addAttachable(cr); addStyleName("x-spinner-field"); trigger.addStyleName("x-form-spinner-up"); twinTrigger.addStyleName("x-form-spinner-down"); setMaxValue(maxValue); setMinValue(minValue); getInputEl().dom.setAttribute("role", "spinbutton"); keyNav = new KeyNav<ComponentEvent>(this) { @Override public void onDown(ComponentEvent ce) { doSpin(false); } @Override public void onUp(ComponentEvent ce) { doSpin(true); } }; }