View previous topic :: View next topic |
Author |
Message |
LastExceed Expert Cheater Reputation: 1
Joined: 05 Nov 2014 Posts: 130
|
Posted: Wed Nov 04, 2015 10:19 am Post subject: How do I customize the look of Buttons ect? |
|
|
I don't know how it's called in lua, but in java there was "look and feel" which allowed you to pick a preset of graphics for UI elements or to create your own. Is it possible to customize them here too? if yes how? (sfmbe)
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Wed Nov 04, 2015 11:04 am Post subject: |
|
|
No (well, you could rip out the manifest from the exe and make the gui look like a windows 95 screen, but those are the two options)
if you want customizable buttons, you have to draw them yourself. (use the canvas and handle mousedown and mouseup as a click)
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
LastExceed Expert Cheater Reputation: 1
Joined: 05 Nov 2014 Posts: 130
|
Posted: Wed Nov 04, 2015 11:47 am Post subject: |
|
|
Dark Byte wrote: | No (well, you could rip out the manifest from the exe and make the gui look like a windows 95 screen, but those are the two options)
if you want customizable buttons, you have to draw them yourself. (use the canvas and handle mousedown and mouseup as a click) |
I'm fine with 'drawing' them myself, but i didn't quite understand how to use the custom graphics. Can you explain that a little more precisely please?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Wed Nov 04, 2015 2:28 pm Post subject: |
|
|
here is a crappy button example.
Code: |
f=createForm()
pb=createPaintBox(f)
--"button" code
down=false
pb.Width=100;
pb.Height=25;
pb.OnPaint=function (s)
local buttontext="Click me"
if down then
s.Canvas.Brush.Color=0x00ff00
else
s.Canvas.Brush.Color=0xff0000
end
s.Canvas.fillRect(0,0,s.Width, s.Height)
s.Canvas.Font.Color=0
local tw=s.Canvas.getTextWidth(buttontext)
local th=s.Canvas.getTextHeight(buttontext)
local xpos=math.floor((s.width/2.0)-(tw/2.0))
local ypos=math.floor((s.height/2.0)-(th/2.0))
pb.Canvas.textOut(xpos,ypos,buttontext)
end
pb.OnMouseDown=function(s)
down=true
s.OnPaint(s)
end
pb.OnMouseUp=function(s)
down=false
s.OnPaint(s)
end
pb.OnClick=function(s)
print("handle my click")
end
|
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
LastExceed Expert Cheater Reputation: 1
Joined: 05 Nov 2014 Posts: 130
|
Posted: Wed Nov 04, 2015 2:30 pm Post subject: |
|
|
Dark Byte wrote: | here is a crappy button example.
Code: |
f=createForm()
pb=createPaintBox(f)
--"button" code
down=false
pb.Width=100;
pb.Height=25;
pb.OnPaint=function (s)
local buttontext="Click me"
if down then
s.Canvas.Brush.Color=0x00ff00
else
s.Canvas.Brush.Color=0xff0000
end
s.Canvas.fillRect(0,0,s.Width, s.Height)
s.Canvas.Font.Color=0
local tw=s.Canvas.getTextWidth(buttontext)
local th=s.Canvas.getTextHeight(buttontext)
local xpos=math.floor((s.width/2.0)-(tw/2.0))
local ypos=math.floor((s.height/2.0)-(th/2.0))
pb.Canvas.textOut(xpos,ypos,buttontext)
end
pb.OnMouseDown=function(s)
down=true
s.OnPaint(s)
end
pb.OnMouseUp=function(s)
down=false
s.OnPaint(s)
end
pb.OnClick=function(s)
print("handle my click")
end
|
|
so all i can do is change the color?
|
|
Back to top |
|
|
Dark Byte Site Admin Reputation: 458
Joined: 09 May 2003 Posts: 25295 Location: The netherlands
|
Posted: Wed Nov 04, 2015 2:44 pm Post subject: |
|
|
this is just an example. You can also draw bitmaps and other stuff, but the basis is the same. A paintbox that draws the image and mouse events that do 'special' things, like drawing a different bitmap
Look up the Canvas class
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.
Like my help? Join me on Patreon so i can keep helping |
|
Back to top |
|
|
LastExceed Expert Cheater Reputation: 1
Joined: 05 Nov 2014 Posts: 130
|
Posted: Wed Nov 04, 2015 3:02 pm Post subject: |
|
|
Dark Byte wrote: | this is just an example. You can also draw bitmaps and other stuff, but the basis is the same. A paintbox that draws the image and mouse events that do 'special' things, like drawing a different bitmap
Look up the Canvas class |
alright, thanks.
|
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Thu Dec 03, 2015 10:57 am Post subject: |
|
|
I make custom buttons by using the image class.
onMouseLeave = basic sprite
onMouseEnter = loading a different sprite into the image object
You may also add another sprite onMouseDown which will make the image look as if it was a button.
_________________
|
|
Back to top |
|
|
LastExceed Expert Cheater Reputation: 1
Joined: 05 Nov 2014 Posts: 130
|
Posted: Thu Dec 03, 2015 11:00 am Post subject: |
|
|
DaSpamer wrote: | I make custom buttons by using the image class.
onMouseLeave = basic sprite
onMouseEnter = loading a different sprite into the image object
You may also add another sprite onMouseDown which will make the image look as if it was a button. |
So you simply use images as buttons that changes to a picture of a specific button state depending on your mouse actions?
|
|
Back to top |
|
|
DaSpamer Grandmaster Cheater Supreme Reputation: 52
Joined: 13 Sep 2011 Posts: 1578
|
Posted: Sat Dec 05, 2015 9:13 am Post subject: |
|
|
Yes, exactly.
Once mouse is hovering, it'd change to different pic, when it's not, return to default, while mouse is holding change state to different pic and on release return to hovering state.
I prefer that method over drawing manually.
_________________
|
|
Back to top |
|
|
LastExceed Expert Cheater Reputation: 1
Joined: 05 Nov 2014 Posts: 130
|
Posted: Sat Dec 05, 2015 9:44 am Post subject: |
|
|
DaSpamer wrote: | Yes, exactly.
Once mouse is hovering, it'd change to different pic, when it's not, return to default, while mouse is holding change state to different pic and on release return to hovering state.
I prefer that method over drawing manually. |
Sounds quite simple, thanks for the idea!
|
|
Back to top |
|
|
|