Can not get control back from an Applet to the main sketch
in
Contributed Library Questions
•
1 year ago
Hi,
I am using processing 2.0 to create an application to display graphs and tabular data. I have created an applet and did a show(false) to keep it hidden.
After I close the applet using the X icon ( renderCloseButton()), I am not able to type anything in the ControlP5 textfields on the main sketch.
Any ideas?
Best,
Bisht
I am using processing 2.0 to create an application to display graphs and tabular data. I have created an applet and did a show(false) to keep it hidden.
- class BApplet extends PApplet
{
int aScaleFactor;
Integer tabPositionx, tabPositiony, tabWidth, tabHeight;
Integer tabColor;
ControlP5 cp5Applet;
static public void main(String args[])
{
PApplet.main(new String[] { "BApplet" });
}
public void setup()
{
//size(400, 300);
cp5Applet = new ControlP5(this);
cp5Applet.setBroadcast(true);
data = "";
label = "";
addTextArea(#7A5200, 50 * scaleFactor, 50 * scaleFactor, 800 * scaleFactor, 800 * scaleFactor);
//noLoop();
}
public void mousePressed()
{
if (mouseX > 10 * aScaleFactor && mouseX < 30 * aScaleFactor)
{
if (mouseY > 10 * aScaleFactor && mouseY < 30 * aScaleFactor)
show(false);
}
}
void renderCloseButton()
{
fill(#7A0029);
rect(10, 10, 20, 20);
noFill();
strokeWeight(1);
stroke(0,0,0);
line(10,10,30,30);
line(10,30,30,10);
}
void addTextArea(Integer colr, Integer px, Integer py, Integer swid, Integer sht)
{
tabPositionx = px;
tabPositiony = py;
tabWidth = swid;
tabHeight = sht;
tabColor = colr;
textTable = cp5Applet.addTextarea("DataTable");
textTable.setPosition( tabPositionx * aScaleFactor, tabPositiony * aScaleFactor);
textTable.setSize( tabWidth * aScaleFactor, tabHeight * aScaleFactor);
textTable.setFont(createFont("arial", 15));
textTable.setLineHeight(17);
textTable.setColor(color(128));
textTable.setColorBackground(color(255,100));
textTable.setColorForeground(color(255,100));
//textTable.setScrollActive(color(255));
//textTable.showScrollbar();
}
}
- BApplet appl_table;
appl_table = new BApplet();
add(appl_table);
appl_table.init();
appl_table.show(false);
- if (controlName == "Table")
{
//println("Plot button was pressed" );
String data = computeDataForTableWindow();
String label = subGraphs[currentTab].graphTitle;
appl_table.setDataToShow ( data, label );
appl_table.show(true);
return;
}
After I close the applet using the X icon ( renderCloseButton()), I am not able to type anything in the ControlP5 textfields on the main sketch.
Any ideas?
Best,
Bisht
1