Problem description:
I have this inventory system where if you click once it'll display the item's description via interface. But if you dblclick(), it equips said gear / does as needed with the item. This is working and all but how would I go about detecting whether somebody clicked or dblclicked? right now when I dblclick it equips the item but also shows me the item's info, a behavior which is only intended if a player clicks once.
Help is much appreciated
-Thanks
![]() Feb 9 2014, 9:48 am
|
|
That's what I'm doing. It's just that when I click twice, it also does what it's supposed to do when I only click once
|
Alright. My code is rather long though:
#define WEAPONS_1 FLOAT_LAYER -1 |
It's just that when I click twice, it also does what it's supposed to do when I only click once So when u click twice it does what you want it to do but it also does what is supposed to do when u click once ? |
Falcon lazorz wrote:
Upon DblClick() undo the Click() effects. That's just silly. Try using a timeout system to make sure only one of them can happen at once. var/tmp/double_clicked You could probably only use Click() by itself with the right check, but then what would be the point of DblClick()? Hopefully this works like I think it would. Edit: After actually testing this out, I realized that I would need to make sure that 2 Click() calls got cancelled, not just 1. That much should have been obvious to me... Also, upon testing I discovered that all that was needed was a simple sleep() call to get the timing right, not any kind of fancy loop. In fact, trying to do this with loops was just really buggy, so this new system is surprisingly much more stable. The above code has been edited. |
I updated the code with a new version that should work far better.
Sorry if it had caused any issues. |
You don't even really need to get that fancy.
obj DblClick() doesn't really need to be altered since the problem is just the second click of a double-click triggering Click(), adding a delay between the ability to execute Click() is more than enough to prevent that from happening. Click once -> Success Click twice (within half a tick) -> Failure, but DblClick() executes. |
That might work in specific cases, but not all. Your method really only solves half of the problem. Click() is normally called twice whenever DblClick() is called, so both calls to Click() need to be cancelled, otherwise you will still end up doing both what Click() does and what DblClick() does.
The way I understand it is that there is a conflict between the functionalities of each proc, and the OP only wants a single call in each case (either 1 Click() or 1 DblClick()). I guess it just depends on how you are setting things up. |
I would just like to share on how I would do this.
mob/proc/Equip_Item(var/obj/o) |