04-08-2018, 02:00 PM
(This post was last modified: 04-09-2018, 03:58 PM by Rick Johnson.)
I implemented a checkbox to turn previewing on, but its behavior is a bit erratic. The checkbox's callback dismisses and then shows the dialog, then it seems to forget it has a callback until clicked again several times. When it does get called, it works correctly. Reassigning the callback with PreviewChk.setClickCallback(...)) at the end of the callback doesn't help. The stepper widget may provide some clues. If the dialog is dismissed and then shown again, on the first click it gets "stuck" in the pressed position, then the second click calls the callback just fine.
Is it possible that some context operations could solve this issue? Hot Door's NitPicker has a preview function; is that done with annotations?
For the benefit of others, the OK and Cancel callbacks work fine. The callback for Cancel deletes this->previewArt if it exists. The callback for OK deletes this->previewArt if it exists, then calls goDrawSomething();
Code:
// some variables declared in the .hpp header
hdi::core::ModalDialog modalDlg
hdi::core::Checkbox PreviewChk
hdi::core::Art previewArt
bool PreviewOn;
hdi::core::Art goDrawSomething();
// the checkbox's callback in the .cpp file
void thePlugin::Plugin::__doPreviewChkCB(){
this->modalDlg.dismiss();
this->PreviewOn = (this->PreviewChk.state() == hdi::core::Checkbox::StateOn);
if (!this->previewArt.isEmpty())
this->previewArt.dispose();
if (this->PreviewOn)
this->previewArt = goDrawSomething();
HDI_CORE_ILLUSTRATOR->currentDocument()->redraw();
this->modalDlg.show();
}
Is it possible that some context operations could solve this issue? Hot Door's NitPicker has a preview function; is that done with annotations?
For the benefit of others, the OK and Cancel callbacks work fine. The callback for Cancel deletes this->previewArt if it exists. The callback for OK deletes this->previewArt if it exists, then calls goDrawSomething();