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_
|
_example 1, see code below_
|
||||||
|
|
||||||
|
|
||||||
|
@ -124,7 +124,6 @@ public class Button extends Controller< Button > {
|
|||||||
isActive = false;
|
isActive = false;
|
||||||
isOn = !isOn;
|
isOn = !isOn;
|
||||||
setValue( _myValue );
|
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 ) {
|
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 );
|
ScrollableList myController = new ScrollableList( base.cp5 , ( Tab ) base.cp5.controlWindow.getTabs( ).get( 1 ) , theName , theX , theY , theW , theH );
|
||||||
base.cp5.register( theObject , theIndex , myController );
|
base.cp5.register( theObject , theIndex , myController );
|
||||||
myController.registerProperty( "listBoxItems" ).registerProperty( "value" );
|
myController.registerProperty( "items" ).registerProperty( "value" );
|
||||||
return myController;
|
return myController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -695,6 +695,7 @@ public abstract class Controller< T > implements ControllerInterface< T > , CDra
|
|||||||
cp5.getControlBroadcaster( ).invokeAction( new CallbackEvent( this , ACTION_LEAVE ) );
|
cp5.getControlBroadcaster( ).invokeAction( new CallbackEvent( this , ACTION_LEAVE ) );
|
||||||
_myControlWindow.removeMouseOverFor( this );
|
_myControlWindow.removeMouseOverFor( this );
|
||||||
cp5.getTooltip( ).deactivate( );
|
cp5.getTooltip( ).deactivate( );
|
||||||
|
setIsInside( false ); /* added after issue 6 has been reported */
|
||||||
}
|
}
|
||||||
return me;
|
return me;
|
||||||
}
|
}
|
||||||
|
@ -134,35 +134,43 @@ public class ScrollableList extends Controller< ScrollableList > implements Cont
|
|||||||
|
|
||||||
// n += itemRange; /* UP */
|
// n += itemRange; /* UP */
|
||||||
int index = ( int ) n + itemIndexOffset;
|
int index = ( int ) n + itemIndexOffset;
|
||||||
|
updateIndex( index );
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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( ) {
|
@Override protected void onDrag( ) {
|
||||||
scroll( getPointer( ).dy( ) );
|
scroll( getPointer( ).dy( ) );
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user