mirror of
https://github.com/sojamo/controlp5
synced 2024-11-22 14:07:55 +01:00
Fix to Issue #40
Added check if index is in range before using it to index the list of items.
This commit is contained in:
parent
665b0c1aa5
commit
9eedf3ad45
@ -127,24 +127,26 @@ public class DropdownList extends Controller< DropdownList > implements ControlL
|
|||||||
// n += itemRange; /* UP */
|
// n += itemRange; /* UP */
|
||||||
int index = ( int ) n + itemIndexOffset;
|
int index = ( int ) n + itemIndexOffset;
|
||||||
|
|
||||||
Map m = items.get( index );
|
if (index < items.size()) {
|
||||||
|
Map m = items.get( index );
|
||||||
switch ( _myType ) {
|
|
||||||
case ( LIST ):
|
switch ( _myType ) {
|
||||||
setValue( index );
|
case ( LIST ):
|
||||||
for ( Object o : items ) {
|
setValue( index );
|
||||||
( ( Map ) o ).put( "state" , false );
|
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;
|
||||||
}
|
}
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user