Page 1 of 1

Padding on button icon?

Posted: Tue Oct 15, 2013 10:42 pm
by nextyoyoma
I am using the following code to generate a game board for a project. The board consists of a grid of buttons, the number of which is specified in field "field" (just temporary name, obviously).

Code: Select all

on openCard
   set the height of the templateButton to 30
   set the width of the templateButton to 30
   set the borderWidth of templateButton to 0
   set the shadowoffset of templatebutton to 0
   create group
end openCard

command makeBoard
   put fld "field" into rowCount
   put fld "field" into colCount
   add 30 to locStartX
   put 30 into locStartY
   lock screen
   repeat with x =1 to rowCount
      repeat with y =1 to colCount
         if locStartX is (30 * colCount + 30) then
            put 30 into locStartX
            add 30 to locStartY
         end if
         create button in first group
         put it into newButtonID
         put the long id of newButtonID into boardArray[x][y]
         set the loc of newButtonID to locSTartx,locstarty
         add 30 to locStartX
      end repeat
   end repeat
   unlock screen
end makeBoard
The problem is that while the buttons are aligned perfectly, there is a space of about 3 pixels at the bottom of each button. If you click on the button, you can see that the icon is not taking up the entirety of the rect. This also seems to be the case when creating a new button. Other than using a custom icon, is there any way to change this behavior? I can't find any property that obviously corresponds to this behavior.

Re: Padding on button icon?

Posted: Tue Oct 15, 2013 10:58 pm
by Simon
Hi nextyoyoma,
I just made a stack and ran your code (very nice button layout). I think you want to turn off 3D in the icons & borders and set the border width to 1, that way you can see that the buttons are right up against each other.
I could have this wrong as I can see a space all around the 3D button not just at the bottom.

If you need the button look, then yes a custom icon will do.

Simon

Re: Padding on button icon?

Posted: Tue Oct 15, 2013 11:39 pm
by bn
Hi nextyoyoma,

try to add

Code: Select all

  set the style of the templateButton to "rectangle"
to your opencard handler. For me it takes away the 2 pixel at the bottom of the button. This is on a Mac.

Kind regards
Bernd

Re: Padding on button icon?

Posted: Wed Oct 16, 2013 1:06 am
by nextyoyoma
bn wrote:Hi nextyoyoma,

try to add

Code: Select all

  set the style of the templateButton to "rectangle"
to your opencard handler. For me it takes away the 2 pixel at the bottom of the button. This is on a Mac.

Kind regards
Bernd
That's it! Thanks!