diff --git a/README.md b/README.md index e41375f..4989c06 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ To get started, here a simple example that demonstrates how to create a slider a -![example 1](resources/images/cp5-example-1_s.png) +![example 1](./resources/images/cp5-example-1_s.png) _example 1, see code below_ diff --git a/src/controlP5/Button.java b/src/controlP5/Button.java index 771b28f..c257130 100755 --- a/src/controlP5/Button.java +++ b/src/controlP5/Button.java @@ -124,7 +124,6 @@ public class Button extends Controller< Button > { isActive = false; isOn = !isOn; setValue( _myValue ); - } } diff --git a/src/controlP5/ControlP5Legacy.java b/src/controlP5/ControlP5Legacy.java index 67c7af8..2657469 100644 --- a/src/controlP5/ControlP5Legacy.java +++ b/src/controlP5/ControlP5Legacy.java @@ -294,7 +294,7 @@ public class ControlP5Legacy { public ScrollableList addScrollableList( final Object theObject , String theIndex , final String theName , final int theX , final int theY , final int theW , final int theH ) { ScrollableList myController = new ScrollableList( base.cp5 , ( Tab ) base.cp5.controlWindow.getTabs( ).get( 1 ) , theName , theX , theY , theW , theH ); base.cp5.register( theObject , theIndex , myController ); - myController.registerProperty( "listBoxItems" ).registerProperty( "value" ); + myController.registerProperty( "items" ).registerProperty( "value" ); return myController; } diff --git a/src/controlP5/Controller.java b/src/controlP5/Controller.java index 0b952ae..05f1762 100755 --- a/src/controlP5/Controller.java +++ b/src/controlP5/Controller.java @@ -695,6 +695,7 @@ public abstract class Controller< T > implements ControllerInterface< T > , CDra cp5.getControlBroadcaster( ).invokeAction( new CallbackEvent( this , ACTION_LEAVE ) ); _myControlWindow.removeMouseOverFor( this ); cp5.getTooltip( ).deactivate( ); + setIsInside( false ); /* added after issue 6 has been reported */ } return me; } diff --git a/src/controlP5/ScrollableList.java b/src/controlP5/ScrollableList.java index b2bc161..54fe575 100644 --- a/src/controlP5/ScrollableList.java +++ b/src/controlP5/ScrollableList.java @@ -134,35 +134,43 @@ public class ScrollableList extends Controller< ScrollableList > implements Cont // n += itemRange; /* UP */ int index = ( int ) n + itemIndexOffset; - - if ( index >= items.size( ) ) { - return; - } - - Map m = items.get( index ); - - switch ( _myType ) { - case ( LIST ): - setValue( index ); - for ( Object o : items ) { - ( ( Map ) o ).put( "state" , false ); - } - m.put( "state" , !ControlP5.b( m.get( "state" ) ) ); - break; - case ( DROPDOWN ): - setValue( index ); - setOpen( false ); - getCaptionLabel( ).setText( ( m.get( "text" ).toString( ) ) ); - break; - case ( CHECKBOX ): - m.put( "state" , !ControlP5.b( m.get( "state" ) ) ); - break; - } - + updateIndex( index ); } } } + private void updateIndex( int theIndex ) { + if ( theIndex >= items.size( ) ) { + return; + } + + Map m = items.get( theIndex ); + + switch ( _myType ) { + case ( LIST ): + super.setValue( theIndex ); + for ( Object o : items ) { + ( ( Map ) o ).put( "state" , false ); + } + m.put( "state" , !ControlP5.b( m.get( "state" ) ) ); + break; + case ( DROPDOWN ): + super.setValue( theIndex ); + setOpen( false ); + getCaptionLabel( ).setText( ( m.get( "text" ).toString( ) ) ); + break; + case ( CHECKBOX ): + m.put( "state" , !ControlP5.b( m.get( "state" ) ) ); + break; + } + + } + + public ScrollableList setValue( float theValue ) { + updateIndex( ( int ) ( theValue ) ); + return this; + } + @Override protected void onDrag( ) { scroll( getPointer( ).dy( ) ); }