events are sent only to active controller

This commit is contained in:
Gabriel Salvador 2023-07-05 16:27:56 +01:00
parent 8f79b27cb1
commit b4d6768f73
18 changed files with 39 additions and 3 deletions

14
.idea/aws.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="accountSettings">
<option name="activeRegion" value="us-east-1" />
<option name="recentlyUsedRegions">
<list>
<option value="us-east-1" />
</list>
</option>
</component>
<component name="connectionManager">
<option name="activeConnectionId" value="sso;us-east-1;https://view.awsapps.com/start" />
</component>
</project>

View File

@ -1197,6 +1197,7 @@ public abstract class Controller< T > implements ControllerInterface< T > , CDra
}
protected void mousePressed( ) {
( (ControllerGroup<?>) _myParent).setActiveController(this);
}
protected void mouseReleased( ) {

View File

@ -23,7 +23,7 @@ package controlP5;
* @modified ##date##
* @version ##version##
*
*/
**/
import java.util.ArrayList;
import java.util.List;
@ -43,6 +43,9 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > ,
protected float[] positionBuffer = new float[ 2 ];
protected float[] absolutePosition = new float[ 2 ];
protected ControllerList controllers;
/* the controller that receives KeyEvents*/
protected Controller<?> activeController;
protected List< ControlListener > _myControlListener;
// protected ControlWindow _myControlWindow;
protected ControlP5 cp5;
@ -540,11 +543,25 @@ public abstract class ControllerGroup< T > implements ControllerInterface< T > ,
}
@ControlP5.Invisible public void keyEvent( KeyEvent theEvent ) {
for ( int i = 0 ; i < controllers.size( ) ; i++ ) {
( ( ControllerInterface< ? > ) controllers.get( i ) ).keyEvent( theEvent );
//for ( int i = 0 ; i < controllers.size( ) ; i++ ) {
// ( ( ControllerInterface< ? > ) controllers.get( i ) ).keyEvent( theEvent );
//}
if ( activeController != null ){
activeController.keyEvent(theEvent);
}
}
public ControllerGroup<T> setActiveController(Controller<?> theController){
activeController = theController;
return this;
}
public Controller<?> getActiveController(){
return activeController;
}
public boolean setMousePressed( boolean theStatus ) {
if ( !isVisible ) {
return false;

View File

@ -260,6 +260,8 @@ public class Textfield extends Controller< Textfield > implements ReleasedOutsid
}
@Override protected void mousePressed( ) {
super.mousePressed();
if ( isActive ) {
// TODO System.out.println("adjust cursor");
}
@ -268,6 +270,8 @@ public class Textfield extends Controller< Textfield > implements ReleasedOutsid
// TODO System.out.println(x + ":" + y);
setFocus( true );
}
@Override public void mouseReleasedOutside( ) {