I'm facing two major problem atm.
The moving method suggested works very well when i set noLoop in setup(). But with noLoop the interface (controlP5 tab) doesn't higligh when mouse is hover and doesn't flash when mouse is pressed.
The interface behave correctly if i omit noLoop() but the controlP5 library is loaded at each draw() call so that the application is getting slow. And the component move oddly (certainly due to the issue ben pointed me out).
Here's the source code as i'm sure there could be a lot better. Any suggestion for enhancement would be very appreciated.
PreRequisGUI.pde
Quote:import controlP5.*;
import java.awt.datatransfer.*;
int offsetX, offsetY =0;
boolean CopySherpa, CopyAunis = false;
boolean Movable = false;
String PRAunis[], PRSherpa[];
String PRAunisString, PRSherpaString;
ControlP5 ctrlP5;
CopyPaste copypaste;
/*
static public void main(String args[]) {
PApplet.main(new String[] {
"--location=800,0", "PreRequisGUI"
}
);
}
*/
void setup(){
size(100, 16);
copypaste= new CopyPaste();
PRAunis = loadStrings("PRAunis.txt", "ISO-8859-1");
PRSherpa = loadStrings("PRSherpa.txt", "ISO-8859-1");
background(0);
fill(0);
smooth();
guiInit();
this.frame.setResizable(true);
this.frame.setAlwaysOnTop(true);
this.frame.setUndecorated(true);
//noLoop();
}
void draw(){
this.frame.setSize(width, height);
guiInit();
}
void getTabContent(){
if (CopyAunis){
PRAunisString = join(PRAunis, "\r\n");
copypaste.sendString(PRAunisString);
println(PRAunisString);
CopyAunis = !CopyAunis;
}
if (CopySherpa){
PRSherpaString = join(PRSherpa, "\r\n");
copypaste.sendString(PRSherpaString);
println(PRSherpaString);
CopySherpa = !CopySherpa;
}
}
void mousePressed(){
offsetX = mouseX;
offsetY = mouseY;
getTabContent();
}
void mouseDragged(){
this.frame.setCursor(Cursor.MOVE_CURSOR);
Point p = frame.getLocationOnScreen();
this.frame.setLocation(p.x+mouseX-offsetX,p.y+mouseY-offsetY);
}
void mouseReleased(){
this.frame.setCursor(Cursor.DEFAULT_CURSOR);
}
void controlEvent (ControlEvent theEvent){
if (theEvent.isTab()) {
println("tab : "+theEvent.tab().id()+" / "+theEvent.tab().name()+" /"+theEvent.tab().stringValue());
switch(theEvent.tab().id()){
case 0:
CopyAunis = true;
break;
case 1:
CopySherpa = true;
break;
}
}
}
GUI.pde
Quote:void guiInit(){
ctrlP5 = new ControlP5(this);
ctrlP5.remove("default");
Tab AunisTab = ctrlP5.addTab("Aunis");
Tab SherpaTab = ctrlP5.addTab("Sherpa");
AunisTab.setId(0);
SherpaTab.setId(1);
AunisTab.setWidth(50);
SherpaTab.setWidth(50);
AunisTab.activateEvent(true);
SherpaTab.activateEvent(true);
ctrlP5.update();
}
The other two tabs doesn't really matter with my current problems.
Best regards,
O.