Page 1 of 1
How to trap deleteCard?
Posted: Fri Jun 29, 2007 7:50 am
by Timothy
Code: Select all
on deleteCard
if the cantDelete of this card is "true" then
answer "You must unlock the padlock icon before you can delete this card."
else
pass deleteCard
end if
end deleteCard
The button with the padlock icon sets the cantDelete of the card to true or false. (It's not quite that simple. The padlock icon gets set on openCard, but I won't bore you with the details.)
I tried checking the icon ID of the padlock button instead of the cantdelete property of the card, but that didn't work, either. I also tried On doMenu...
I see from the docs that I can't trap the deleteCard message. And, in fact, the deleteCard message doesn't seem to appear in the message watcher. So it's not surprising that the script doesn't work.
The way it works now, if the cantdelete of the card is set to true and I choose "Delete Card" from the "Object" menu, I get the "are you sure you want to delete this card?" message, but nothing happens when I choose "Yes." The on deleteCard script seems to be ignored entirely.
I suppose one approach would be to set the cantdelete of all cards to true, forget about using the Delete Card menu item, and to make a "delete card" button instead. But maybe there's a better way.
Thanks,
Tim
Posted: Fri Jun 29, 2007 9:08 am
by Mark
Hi Tim,
Probably, a Revolution script prevents you from handing the deleteCard message yourself. I'd consider this a Rev bug.
Note the remark in the docs: The actual deletion is not triggered by the deleteCard message, so trapping the message and not allowing it to pass does not prevent the card from being removed.
Best,
Mark
Posted: Fri Jun 29, 2007 7:16 pm
by Timothy
Hi Mark,
Thanks for your help. I hadn't thought of this issue as a bug, but I did wonder why it's not possible to trap deleteCard. Maybe there's a good reason for it, but none has occurred to me, or you.
I was surprised to find what happens if you choose "Delete Card" from the object menu when the cantdelete of the card is set to true. You get the "are you sure you want to delete this card" dialog from Rev, but nothing happens when you click on "Yes." Ideally, in that case, Rev would put up a dialog box that said, "Can't delete protected card," or words to that effect.
This might not rise to the level of a bug, but is inelegant and slightly user hostile.
It looks like you can't trap "newcard" either, and I suppose there are several similar issues.
Cheers,
Tim
Posted: Fri Jun 29, 2007 7:22 pm
by Mark
Hi Tim,
It seems you have found at least 3 bugs. Could you please report them to the QCC and post the bug numbers here?
Thanks!
Mark