mirror of
https://github.com/sojamo/controlp5
synced 2024-11-22 14:07:55 +01:00
fix for issue #12
This commit is contained in:
parent
096c553452
commit
12235cb462
@ -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_
|
||||
|
||||
|
||||
|
@ -124,7 +124,6 @@ public class Button extends Controller< Button > {
|
||||
isActive = false;
|
||||
isOn = !isOn;
|
||||
setValue( _myValue );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -134,23 +134,28 @@ public class ScrollableList extends Controller< ScrollableList > implements Cont
|
||||
|
||||
// n += itemRange; /* UP */
|
||||
int index = ( int ) n + itemIndexOffset;
|
||||
updateIndex( index );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( index >= items.size( ) ) {
|
||||
private void updateIndex( int theIndex ) {
|
||||
if ( theIndex >= items.size( ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
Map m = items.get( index );
|
||||
Map m = items.get( theIndex );
|
||||
|
||||
switch ( _myType ) {
|
||||
case ( LIST ):
|
||||
setValue( index );
|
||||
super.setValue( theIndex );
|
||||
for ( Object o : items ) {
|
||||
( ( Map ) o ).put( "state" , false );
|
||||
}
|
||||
m.put( "state" , !ControlP5.b( m.get( "state" ) ) );
|
||||
break;
|
||||
case ( DROPDOWN ):
|
||||
setValue( index );
|
||||
super.setValue( theIndex );
|
||||
setOpen( false );
|
||||
getCaptionLabel( ).setText( ( m.get( "text" ).toString( ) ) );
|
||||
break;
|
||||
@ -160,7 +165,10 @@ public class ScrollableList extends Controller< ScrollableList > implements Cont
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public ScrollableList setValue( float theValue ) {
|
||||
updateIndex( ( int ) ( theValue ) );
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override protected void onDrag( ) {
|
||||
|
Loading…
Reference in New Issue
Block a user