Open rodri16 opened 5 years ago
I have the same problem with IFButton's. The last button is still visible on the canvas when trying to remove all of them.
Thank you for documenting this. I've been able to reproduce the issue and I'm currently looking into it.
I was having this problem with 6 buttons that were permanent, and two that I added and removed. The following strategy seems to have worked for me:
IFButton okButton, cancelButton;
void addOKButton()
{
int buttonY = 5 + buttonSpacingY * 5;
okButton = new IFButton("OK", (int)guiOffset.x + buttonRowAX, (int)guiOffset.y + buttonY, buttonWidth, buttonHeight);
okButton.addActionListener(this);
gui.add(okButton);
}
void addCancelButton()
{
int buttonY = 5 + buttonSpacingY * 5;
cancelButton = new IFButton("Cancel", (int)guiOffset.x + buttonRowBX, (int)guiOffset.y + buttonY, buttonWidth, buttonHeight);
cancelButton.addActionListener(this);
gui.add(cancelButton);
}
void removeOKButton()
{
gui.remove(okButton);
//Set to null so the button isn't reused. Avoids some kind of mouse event already assigned exception.
okButton = null;
}
void removeCancelButton()
{
gui.remove(cancelButton);
//Set to null so the button isn't reused. Avoids some kind of mouse event already assigned exception.
cancelButton = null;
}
void showConfirmDialog(GUIEvent e)
{
hideConfirmDialog(); //Get rid of any existing dialog
confirmGuiEvent = e;
addOKButton();
addCancelButton();
}
void hideConfirmDialog()
{
//Remove them in the opposite order
removeCancelButton();
removeOKButton();
confirmGuiEvent = null;
}
Calling the showConfirmDialog() and the hideConfirmDialog() successfully adds/removes the buttons, and the buttons function properly (code for that not shown).
Hi, I am using the library to draw a menu with 6 buttons. the problem is that when I try to delete buttons the last one remains in the drawing.
then i do other things and
but b6 remains
If for example I don't add b6, b5 remains. What is the problem?