shift-click with Guibitmapbuttonctrl
by Robert \"Larington\" Farr · in Torque 3D Professional · 05/22/2011 (3:09 pm) · 7 replies
I've spent at least 6 hours now trying to get a button to do something other than command when I shift click on the button, but I've been struggling to wrap my head around the requirements for this to work. I've even tried being cheeky and just trying to pull the value in $EventModifier::SHIFT but this always evaluates as 3 regardless of whether or not shift is being held down. If someone could post a code sample of a guibitmapbuttonctrl with shift-click enabled that I can then look at I would really appreciate it, the documentation on working with GUIs stops short of this information.
Thanks in advance
(Some of my desperate attempts to get things to work are below)
Thanks in advance
(Some of my desperate attempts to get things to work are below)
new GuiBitmapButtonCtrl(MoreGeneralCropsBtn) {
bitmap = "art/gui/colonyStatusMenu/ButtonUp.png";
groupNum = "-1";
buttonType = "PushButton";
useMouseEvents = "0";
isContainer = "0";
Profile = "GuiDefaultProfile";
HorizSizing = "relative";
VertSizing = "relative";
position = "331 57";
Extent = "18 18";
MinExtent = "8 2";
canSave = "1";
Visible = "1";
Command = "makeMoreGeneralCrops();";
tooltipprofile = "GuiToolTipProfile";
hovertime = "1000";
canSaveDynamicFields = "0";
};
function makeMoreGeneralCrops()
{
if((AgricultureCapacityTotal.text - AgricultureCapacity.text) >= 4)
{
AgricultureCapacity.text = AgricultureCapacity.text +4;
ProductionGeneralCrops.text = ProductionGeneralCrops.text +1;
MadeGeneralCrops.text = MadeGeneralCrops.text +1;
updateResultingProductionValues();
}
}
function GuiBitmapButtonCtrl::onShiftClick(%moreGeneralCropsBtn)
{
if((AgricultureCapacityTotal.text - AgricultureCapacity.text) >= 40)
{
AgricultureCapacity.text = AgricultureCapacity.text +40;
ProductionGeneralCrops.text = ProductionGeneralCrops.text +10;
MadeGeneralCrops.text = MadeGeneralCrops.text +10;
updateResultingProductionValues();
}
}
#2
05/22/2011 (4:23 pm)
Just found that I wasn't looking properly... the documentation actually is all there and linked to the onShiftClick() etc. documentation correctly. Look under "Per-Modifier Button Actions".
#3
Thanks muchly.
05/22/2011 (4:25 pm)
The Torquescript manual does mention setting useModifiers to true, but for reasons I wasn't able to determine (probably that I'm supposed to do it in a very specific way) it didn't appear to work. It's why I'd love to see a sample button with useModifiers set to true and a work onshiftclick so I can compare to everything I've tried and see what I missed. Probably messing up callback syntax or something.Thanks muchly.
#4
BTW, rather than adding onShiftClick() to the GuiBitmapButtonCtrl namespace, better add it to the MoreGeneralCropsBtn namespace.
05/22/2011 (4:37 pm)
Hmm, I tried your code with useModifiers=true, and everything worked here.BTW, rather than adding onShiftClick() to the GuiBitmapButtonCtrl namespace, better add it to the MoreGeneralCropsBtn namespace.
#5
05/22/2011 (10:56 pm)
Thanks.
#6
After getting other stuff that needed sorting Mon/Tue I finally got back to the project. Turns out the problem was due to me breaking shift-clicking somehow at some point, either whilst experimenting with controls or due to lazily copy-pasting my project up through different versions of Torque (Those are the most likely causes I think).
I've since created a new project with the latest T3D release and transferred the bulk of the code and assets by themselves into that project and shift-click is working.
05/26/2011 (12:54 am)
Thanks Rene. Looks like I got it working.After getting other stuff that needed sorting Mon/Tue I finally got back to the project. Turns out the problem was due to me breaking shift-clicking somehow at some point, either whilst experimenting with controls or due to lazily copy-pasting my project up through different versions of Torque (Those are the most likely causes I think).
I've since created a new project with the latest T3D release and transferred the bulk of the code and assets by themselves into that project and shift-click is working.
#7
05/26/2011 (12:56 am)
Great!
Associate Rene Damm
$EventModifier::SHIFT is a constant and thus will always be 3. It is only relevant for GuiMouseEventCtrl which passes a modifier mask in its callbacks that you can use $EventModifier::SHIFT et all to test for specific modifiers.