Home Download Buy Blog Forum Support

Preventing a save in "on_pre_save"

Preventing a save in "on_pre_save"

Postby SJML on Thu Feb 17, 2011 3:40 pm

I'm writing a simple Perforce plugin that lets me easily checkout a file from my active Perforce client.

The checkout command works fine, but what I'd like to do now is create an on_pre_save event that looks to see if the file needs to be checked out, pops up a box asking if I'd like to check it out, and does so if I answer yes.

The problem is when I answer no -- is there some way to cancel the save action from within an on_pre_save event?
SJML
 
Posts: 19
Joined: Sat Feb 05, 2011 3:32 am

Re: Preventing a save in "on_pre_save"

Postby gtt on Thu Apr 14, 2011 1:33 pm

Question...how far did you get with this plugin? Does it work with Sublime Text 2? Do you need any help? Would like to use it.

--George
gtt
 
Posts: 5
Joined: Thu Mar 10, 2011 3:18 pm

Re: Preventing a save in "on_pre_save"

Postby SJML on Thu Sep 22, 2011 1:44 pm

Delayed reaction!

I got as far as I needed for my purposes -- essentially when you save, it tries to do a checkout if necessary, and then saves.

What it does not do is prompt the user for confirmation or give you the chance to log in. I wasn't too happy with the input options ST2 offered (at the time anyway; haven't explored it since then), so I made myself content with it just using the system credentials if I was already logged in.

The downside is that if my credentials have expired, it just fails to save, but it's easy enough to pop over to the GUI client (or command line) and refresh them.
SJML
 
Posts: 19
Joined: Sat Feb 05, 2011 3:32 am


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests

cron