HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: [Resolved] GUI Controls Roadblock  (Read 2632 times)


  • General Accounts
  • *
  • Posts: 1
    • View Profile
[Resolved] GUI Controls Roadblock
« on: Aug 13, 10, 11:57:29 AM »

So, I've been fiddling around with various Controls (NumericInputField/NumericUpDownButton) for quite some time now... trying to get a pair (and eventually - several pairs) of NumericUpDownButton (or NumericUpDownDragZone) GUI Controls to modify (increment/decrement) a single, separated NumericInputField Control.

Initially, this seemed like a easy task (and probably still is), but I'm hitting a couple of roadblocks and am having a hard time figuring out a couple of things with these controls. So, here's what I want to do:

1. Have a single NumericInputField (named: "myNIF"), whose value is initially, let's say: 5.
2. Have several NumericUpDownButton Controls (named: "numUP1", "numUP2", "numDN1", etc.) that will increment/decrement the value in "myNIF".

My initial roadblock was this: "The value field in a NumericInputField Control (along with several other Controls) is a String"... therefore, arithmetic operations don't work in this case... there aren't any: "myNIF.value = myNIF.value + 1" or "myNIF.value = myNIF.value - 1" operations. So, I was curious as to how I could "easily" increment and decrement the current value of the InputField without having to do hundreds of IF/THEN statements.

My second roadblock was... "How will I know when a particular UP/DOWN button is clicked?" I tried fishing around in the methods that were available with NumericUpDownButton Controls and I saw that there was a "selected" boolean. I tried checking with: if (numUp1.selected == true), but I don't think it worked out for me either. Is there another way to check whether or not a up/down button control has been selected/clicked? Or did I check this correctly? Is "Selected" the "RIGHT" way of going about it?

I then tried to just make the NumericUpDownButton Controls into just regular Buttons and use the _OnButtonMouseClicked() function... but, this only psuedo-worked the way I wanted it to. I was forced to use/have square boxes opposed to up and down arrows (since it's inherited from _button and _button use the bounded boxes).

So, if anyone can assist me in conquering these two annoying roadblocks, I'd be extremely elated!

« Last Edit: Nov 01, 12, 02:32:06 PM by HE-Cooper »


  • General Accounts
  • *
  • Posts: 2
    • View Profile
Re: GUI Controls Roadblock
« Reply #1 on: Sep 03, 10, 07:30:44 PM »

1.convert the string to an integer and increment from there
2.set the field value to the new number

for the selection of button you use the _OnButtonMouseClicked method. eg:

method _onButtonMouseClick(button as NodeRef of Class _GUIButton, args references Class GUIMouseEvent)
  when button.name
    is "numUP1"
      numField as noderef of class GUINumericField = me.getNumField()
      iValue as integer = numField .value // cast current value to integer
      iValue +=1
      numField .value = iValue
    is "numUP2"

as for button without border, you can create your own custom one.
Just create a new prototype gui, do not select anything on the "Inherit From", and select "_GUIButton" as class.
After, in property panel, set "ignoreMouseEvent" to false.  Set some custom texture and you are set.
« Last Edit: Sep 03, 10, 07:32:31 PM by MP-LUNG »