Ir al contenido principal

Entradas

Mostrando entradas de 2017

Desactivar eventos tipo Spinner en input numérico

// Disable change of values ​​by pressing the cursor keys   $ ( 'input[type="number"]' ). bind ( 'keypress' ,   function ( event )   {        if   ( event )   {          if   ( event . keyCode   ==   38   ||   event . keyCode   ==   40 )   {   // arrow keys           return   false ;          }        }      });      // disable mousewheel on a input number field when in focus     // (to prevent Cromium browsers change the value when scrolling)     $ ( 'html' ). on ( 'focus' ,   'input[type=number]' ,   function ( e )   {        $ ( this ). on ( 'mousewheel.disableScroll' ,   function ( e )   {          e . preventDefault ();        });      });      $ ( 'html' ). on ( 'blur' ,   'input[type=number]' ,   function ( e )   {        $ ( this ). off ( 'mousewheel.disableScroll' );      });   

Custom Event Java

import java.util.* ; // An interface to be implemented by everyone interested in "Hello" events interface HelloListener { void someoneSaidHello (); } // Someone who says "Hello" class Initiater { private List < HelloListener > listeners = new ArrayList < HelloListener >(); public void addListener ( HelloListener toAdd ) { listeners . add ( toAdd ); } public void sayHello () { System . out . println ( "Hello!!" ); // Notify everybody that may be interested. for ( HelloListener hl : listeners ) hl . someoneSaidHello (); } } // Someone interested in "Hello" events class Responder implements HelloListener { @Override public void someoneSaidHello () { System . out . println ( "Hello there..." ); } } // test implementation class Test { public static void main ( String []