Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Event Mouse in a second window with G4P

$
0
0

Hello guys,

Can anyone help as I could control click the button of each button, a second window with G4P?

Below is the sample code ...

import g4p_controls.*;
GWindow window;
GButton btnTest, btnTest2;

public void setup() {
  size(160, 160);
  background(255);

  window = new GWindow(this, "Second Window", 130, 100, 400, 320, false, JAVA2D);
  window.addDrawHandler(this, "windowDraw");
  window.addMouseHandler(this, "windowMouse");
  window.addKeyHandler(this, "keyEvent");
  window.setActionOnClose(G4P.CLOSE_WINDOW);
  window.setLocation(250, 20);

  btnTest  = new GButton(window.papplet, 10, 50, 120, 30, "Test");
  btnTest2 = new GButton(window.papplet, 10, 90, 120, 30, "Test 2");
}

public void draw() {
  background(240);
}

public void windowDraw(GWinApplet appc, GWinData windata) {
  appc.background(255);
}

public void windowMouse(GWinApplet appc, GWinData windata, MouseEvent event) {
  if (event.getAction() == MouseEvent.CLICK) //??
    println("Mouse event in extra window " + frameRate);
}

public void keyEvent(GWinApplet appc, GWinData data, KeyEvent event) {
  if ((event.getAction() == KeyEvent.PRESS) && (appc.keyCode == ESC)) {
    //appc.key = 0;
    appc.keyCode = 0; //??
    println("CTRL Pressed!");
  }
}

More one detail can "cancel" the ESC key, not to close the window?

Thank you


Viewing all articles
Browse latest Browse all 2896

Trending Articles