Page 2 of 3

Re: [HELP] Making a Save button

Posted: Tue Oct 14, 2014 10:48 am
by nice
Positive07 wrote:Save to the save directory... that is your best choice.

Then place other button that says something like "Open containing folder..." and when ever it is pressed trigger the command slime posted before
I had a thought about this, is it too complicated (or impossible) to tell the program that save the image and then open the "containing folder"?

If anyone else has a suggestion, I'm open for it.

Re: [HELP] Making a Save button

Posted: Tue Oct 14, 2014 11:51 am
by Robin
You mean a single button that both saves the image and opens the containing folder? That's neither complicated nor impossible.

Re: [HELP] Making a Save button

Posted: Tue Oct 14, 2014 2:14 pm
by nice
Robin wrote:You mean a single button that both saves the image and opens the containing folder? That's neither complicated nor impossible.
Pretty much, When I'm pleased with the image I press the save button and I want it to open up the containing folder.
Do you have an example how that could be done?

Re: [HELP] Making a Save button

Posted: Tue Oct 14, 2014 2:22 pm
by undef
nice wrote:
Robin wrote:You mean a single button that both saves the image and opens the containing folder? That's neither complicated nor impossible.
Pretty much, When I'm pleased with the image I press the save button and I want it to open up the containing folder.
Do you have an example how that could be done?

Code: Select all

function saveButton()
    saveImage( IMAGENAME )
    openFolder()
end
You just call a function that saves your image and then opens the folder.

Re: [HELP] Making a Save button

Posted: Tue Oct 14, 2014 2:42 pm
by nice
undef wrote:

Code: Select all

function saveButton()
    saveImage( IMAGENAME )
    openFolder()
end
You just call a function that saves your image and then opens the folder.
So I'll need to put that part of the code inside of a clicking function (in this case the save icon) for it to work?

Re: [HELP] Making a Save button

Posted: Tue Oct 14, 2014 3:55 pm
by zorg
Or just call those two from within the clicking function...
that can be as easy as using the love.mousepressed callback, and some math to figure out whether you clicked on your button or not.

Re: [HELP] Making a Save button

Posted: Tue Oct 14, 2014 7:10 pm
by nice
zorg wrote:Or just call those two from within the clicking function...
that can be as easy as using the love.mousepressed callback, and some math to figure out whether you clicked on your button or not.
Could you please elaborate? The first thing I start to think about is true or false statements (as it seem logical to me) and I have a hunch it might sound like this:
If love.mousepressed false then don't do anything
but
if love.mousepressed true then save image and open container folder
Like I said it's the first thing that pops up in my head..

Re: [HELP] Making a Save button

Posted: Tue Oct 14, 2014 8:23 pm
by undef
Did you try what you've suggested?

Code like "if false then end" doesn't do anything, so it can be omited.
Otherwise you're right, but you will have to check whether the mouse is above your button when you click.

Re: [HELP] Making a Save button

Posted: Tue Oct 14, 2014 8:59 pm
by nice
undef wrote:Did you try what you've suggested?

Code like "if false then end" doesn't do anything, so it can be omited.
Otherwise you're right, but you will have to check whether the mouse is above your button when you click.
Well I haven't tried anything yet, it's because it's late where I currently live and I'm tired too but I will give it a try tomorrow.

Re: [HELP] Making a Save button

Posted: Tue Oct 14, 2014 9:34 pm
by DaedalusYoung
No, love.mousepressed is a callback function. LÖVE calls it automatically when the mouse is pressed, it is your job to write the function.

If you wanted to do it the way you described, you could do it with love.mouse.isDown, but that would trigger every frame, as long as you keep the mouse pressed. You'd need to add additional checks for this, and it isn't really intended to be used like this.