Padding on button icon?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
nextyoyoma
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 37
Joined: Sat Oct 06, 2012 6:29 am

Padding on button icon?

Post by nextyoyoma » Tue Oct 15, 2013 10:42 pm

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.

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Padding on button icon?

Post by Simon » Tue Oct 15, 2013 10:58 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 4036
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Padding on button icon?

Post by bn » Tue Oct 15, 2013 11:39 pm

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

nextyoyoma
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 37
Joined: Sat Oct 06, 2012 6:29 am

Re: Padding on button icon?

Post by nextyoyoma » Wed Oct 16, 2013 1:06 am

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!

Post Reply

Return to “Talking LiveCode”