if (clickCount == 2 && mview->isDragging == 0) {
/* Create a new molecular fragment */
- int n1, n2, found;
+ int n1, n2, status, found;
+ char *p;
found = MainView_findObjectAtPoint(mview, mousePos, &n1, &n2, 0, 0);
- buf[0] = 0;
+ status = MyAppCallback_getGlobalSettingsWithType("global.entered_formula", 's', &p);
+ if (status == 0) {
+ strncpy(buf, p, sizeof buf - 1);
+ buf[sizeof buf - 1] = 0;
+ } else {
+ buf[0] = 0;
+ }
if (MyAppCallback_getTextWithPrompt("Enter formula (e.g. CH2OCH3)", buf, sizeof buf) == 0)
return;
+ MyAppCallback_setGlobalSettingsWithType("global.entered_formula", 's', buf);
MolActionCreateAndPerform(mview->mol, SCRIPT_ACTION("si"), "cmd_fuse_or_dock", buf, n1);
goto exit;
}
TransformVec(&offset, mview->mol->cell->rtr, &offset); */
MolActionCreateAndPerform(mview->mol, gMolActionTranslateAtoms, &offset, dupSelection);
IntGroupRelease(dupSelection);
- /* } else if (clickCount == 2) {
- buf[0] = 0;
- if (MyAppCallback_getTextWithPrompt("Enter formula (e.g. CH2OCH3)", buf, sizeof buf) == 0)
- return;
- MolActionCreateAndPerform(mview->mol, SCRIPT_ACTION("s"), "dock_formula", buf);
- */
}
break;
}
/* A Ruby array to retain objects used in MolActionArg */
static VALUE sMolActionArgValues = Qfalse;
+/* A global flag to suppress RubyError dialog during execution */
+int gMolActionNoErrorDialog = 0;
+
/* Action arguments */
/* (Simple types) i: Int, d: double, s: string, v: Vector, t: Transform, u: UnionPar
(Array types) I: array of Int, D: array of double, V: array of Vector, C: array of char, T: array of Transform, U: array of UnionPars
Ruby_SetInterruptFlag(save_interrupt);
MyAppCallback_endUndoGrouping();
}
- if (result != 0) {
+ if (result != 0 && gMolActionNoErrorDialog == 0) {
Ruby_showError(result);
}
MyAppCallback_hideProgressPanel(); /* In case when the progress panel is still onscreen */
#define kMolActionPerformScript "script:s"
#define SCRIPT_ACTION(sig) (kMolActionPerformScript sig)
+/* A global flag to suppress RubyError dialog during execution */
+extern int gMolActionNoErrorDialog;
+
/* Action record for reversible editing */
typedef struct MolAction {
int refCount;
int
MyAppCallback_getGlobalSettingsWithType(const char *key, int type, void *ptr)
{
- int retval;
+ int retval, temp;
char *s = MyAppCallback_getGlobalSettings(key);
char desc[] = SCRIPT_ACTION("s; ");
desc[sizeof(desc) - 2] = type;
+ temp = gMolActionNoErrorDialog;
+ gMolActionNoErrorDialog = 1;
retval = MolActionCreateAndPerform(NULL, desc, "eval", s, ptr);
free(s);
+ gMolActionNoErrorDialog = temp;
return retval;
}
{
const char *cmd = "set_global_settings";
switch (type) {
- case 'i': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("i"), cmd, *((const Int *)ptr));
- case 'd': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("d"), cmd, *((const Double *)ptr));
- case 's': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("s"), cmd, (const char *)ptr);
- case 'v': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("v"), cmd, (const Vector *)ptr);
- case 't': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("t"), cmd, (const Transform *)ptr);
+ case 'i': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("si"), cmd, key, *((const Int *)ptr));
+ case 'd': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("sd"), cmd, key, *((const Double *)ptr));
+ case 's': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("ss"), cmd, key, (const char *)ptr);
+ case 'v': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("sv"), cmd, key, (const Vector *)ptr);
+ case 't': return MolActionCreateAndPerform(NULL, SCRIPT_ACTION("st"), cmd, key, (const Transform *)ptr);
default:
MyAppCallback_errorMessageBox("Internal error: unsupported format '%c' at line %d, file %s", type, __LINE__, __FILE__);
return -2;
sizer1->Layout();
dialog->SetSizerAndFit(sizer1);
dialog->Centre(wxBOTH);
+ tctrl->SelectAll();
tctrl->SetFocus();
}
if (dialog->ShowModal() == wxID_OK) {