PDA

View Full Version : Disable a diecontrol?



Foen
March 7th, 2008, 07:18
Has anyone had much luck disabling a die control? I'd like to determine which dice appear in the control programmatically, rather than have the user fiddle with it.

I can prevent dice being dropped on the control by returning false from an onDrop handler, but the user can still right-click and bring up a 'clear dice' menu item.

The <disable/> switch doesn't seem to do anything, and readonly/static aren't applicable to diecontrols.

I could check for an change in the value, and reset it back to the calculated contents after a user tries to clear it, but this seems rather inelegant. :o

Cheers

Stuart

joshuha
March 7th, 2008, 12:37
Not really a way I know of right now.

The easier thing to to would be create your own die control. So make a generic control, set the Icon to you die type(s) and have a onDrop event to handle the dice and a onDrag one to put dice back into the draginfo.

Foen
March 7th, 2008, 14:05
I thought so. It would be nice if the <disable/> switch worked though.

Thanks Joshuha.

Stuart

Foen
March 7th, 2008, 16:24
Ah-ha! An easier soultion: I've positioned a genericcontrol over the diecontrol. The genericcontrol has nothing to render, but it prevents drop events or menu events from reaching the diecontrol.

Stuart

joshuha
March 7th, 2008, 16:47
The nice thing about your own generic control is you could control the icons of the die betters. Although if your control supports multiple die types its a bit more work to redo that type of stacking you see with the default control.