New Posts New Posts RSS Feed: Does DialogManager have access to the button that is clicked?
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Does DialogManager have access to the button that is clicked?

 Post Reply Post Reply Page  12>
Author
JohnBloom View Drop Down
Groupie
Groupie
Avatar

Joined: 30-Nov-2010
Location: Topeka, KS
Posts: 95
Post Options Post Options   Quote JohnBloom Quote  Post ReplyReply Direct Link To This Post Topic: Does DialogManager have access to the button that is clicked?
    Posted: 11-May-2012 at 6:17am
Thanks for the update. Ill get in there and see what I can do.
-John Bloom
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 08-May-2012 at 4:01pm
John,
I've pushed a minor update (v0.6.1) to NuGet with a fix for the double-click issue. You should no longer see the exception if a user double-clicks on a button. You will also have to update CocktailContrib to 1.0.3 to keep your references straight.
Back to Top
JohnBloom View Drop Down
Groupie
Groupie
Avatar

Joined: 30-Nov-2010
Location: Topeka, KS
Posts: 95
Post Options Post Options   Quote JohnBloom Quote  Post ReplyReply Direct Link To This Post Posted: 19-Apr-2012 at 11:56am
Ok that is fine. We had seen this problem before we updated to Cocktail and we were secretly hoping that you guys had solved it. We can still move forward so it is not a show stopper. The lag is only a split second but enough that people who double click on buttons would have a problem (I know some people who dont see a difference between icons and buttons so they just double click everything). :)
-John Bloom
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 19-Apr-2012 at 11:26am
Neither is a quick fix. When a button is clicked it simply calls TryClose on the outer VM, from that point on it's all Caliburn.Micro. To change the current behavior I have to look into replacing the default closing strategy or worst case implementing my own conductor from scratch. I can't make any promises at this point. Have a bunch of higher prioritiy items on my plate currently.
 
For now the workaround is to disable the buttons yourself or better yet, display a busy indicator. If there's a noticable lag to the user, you should probabaly indicate that the application is doing something.
Back to Top
JohnBloom View Drop Down
Groupie
Groupie
Avatar

Joined: 30-Nov-2010
Location: Topeka, KS
Posts: 95
Post Options Post Options   Quote JohnBloom Quote  Post ReplyReply Direct Link To This Post Posted: 19-Apr-2012 at 6:46am
Thinking about it more, it would be fine if the buttons didn't disable as long as they didnt throw the exception when they were clicked the second time.
-John Bloom
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 18-Apr-2012 at 2:32pm
I have to think about this. Disabling the buttons is easy. Enabling them again if the dialog box doesn't close is a whole other story. The asynchronous nature of the closing makes this very difficult to handle outside of the CanClose where the developer knows when the buttons should be enabled again.
Back to Top
JohnBloom View Drop Down
Groupie
Groupie
Avatar

Joined: 30-Nov-2010
Location: Topeka, KS
Posts: 95
Post Options Post Options   Quote JohnBloom Quote  Post ReplyReply Direct Link To This Post Posted: 18-Apr-2012 at 12:39pm
Because we have logic in the can close there is a little pause before the dialog window disappears. If the user clicks the ok button a second time the dialog manager throws an exception.
System.NotSupportedException: TryClose requires a parent IConductor or a view with a Close method or IsOpen property.
at Caliburn.Micro.Screen.<GetViewCloseAction>b__11()
at Caliburn.Micro.Screen.<TryClose>b__1b()
at Caliburn.Micro.Execute.<>c__DisplayClass2.<InitializeWithDispatcher>b__0(Action action)
at Caliburn.Micro.Execute.OnUIThread(Action action)
at Caliburn.Micro.Screen.TryClose()
at Cocktail.DialogHostBase.Close(DialogButton dialogButton)
In the TemphHire app the view closes too fast to repo this. I added this code to PhoneTypeSelectorViewModel to simulate a canclose that runs async:
public override void CanClose(System.Action<bool> callback)
        {
            System.Threading.Thread.Sleep(1000);
            callback(true);
        }
 
If you click on the ok button a few times while the window is sleeping you will see the error. 
I got around this by disabling all of the buttons when the CanClose is called but that is a lot of maintenance code per view model. 
Maybe the dialog manager can do it automatically?
-John Bloom
Back to Top
JohnBloom View Drop Down
Groupie
Groupie
Avatar

Joined: 30-Nov-2010
Location: Topeka, KS
Posts: 95
Post Options Post Options   Quote JohnBloom Quote  Post ReplyReply Direct Link To This Post Posted: 18-Apr-2012 at 8:21am
Thanks Marcel. I installed it this morning and we are moving forward.
-John Bloom
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 17-Apr-2012 at 6:05pm
John,
You can download the pre-release NuGet packages for Cocktail and CocktailContrib from the following link.

https://skydrive.live.com/redir.aspx?cid=b37183c914f0fbe8&resid=B37183C914F0FBE8!210&parid=B37183C914F0FBE8!208&authkey=!AFFzCj8dMKSPTNg
Back to Top
JohnBloom View Drop Down
Groupie
Groupie
Avatar

Joined: 30-Nov-2010
Location: Topeka, KS
Posts: 95
Post Options Post Options   Quote JohnBloom Quote  Post ReplyReply Direct Link To This Post Posted: 16-Apr-2012 at 10:08am
We use NuGet so that would be the easiest for us.
-John Bloom
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 16-Apr-2012 at 9:20am
I haven't set a release date yet. I'm working on something that may or may not require additional enhancements to Cocktail. In the meantime, you can build the assemblies yourself or I can build them and send to you. If you use NuGet, I can generate pre-release NuGet packages that you could deploy to your own local repository.
Back to Top
JohnBloom View Drop Down
Groupie
Groupie
Avatar

Joined: 30-Nov-2010
Location: Topeka, KS
Posts: 95
Post Options Post Options   Quote JohnBloom Quote  Post ReplyReply Direct Link To This Post Posted: 16-Apr-2012 at 7:05am

Marcel, any idea when version 0.6 will release with the bug fix?

-John Bloom
Back to Top
JChris View Drop Down
Newbie
Newbie
Avatar

Joined: 13-Mar-2012
Location: Kansas
Posts: 8
Post Options Post Options   Quote JChris Quote  Post ReplyReply Direct Link To This Post Posted: 13-Apr-2012 at 11:51am
Sounds great. thanks!
Back to Top
mgood View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 18-Nov-2010
Location: Emeryville, CA
Posts: 583
Post Options Post Options   Quote mgood Quote  Post ReplyReply Direct Link To This Post Posted: 13-Apr-2012 at 11:19am
Better twice than never. :-) Keen observation. That is a bug. I checked in a fix.
Back to Top
JChris View Drop Down
Newbie
Newbie
Avatar

Joined: 13-Mar-2012
Location: Kansas
Posts: 8
Post Options Post Options   Quote JChris Quote  Post ReplyReply Direct Link To This Post Posted: 13-Apr-2012 at 8:18am
In a simplified test, the both CanClose()'s run successfully, however in my implementation (below), the second call errs on the callback(true) with an "Object reference not set".  Thanks,  Chris
        public override void CanClose(Action<bool> callback)
        {
            if (this.DialogHost().DialogResult.Equals(DialogResult.Cancel) == true)
            {
                base.CanClose(callback);
            }
            else
            {
                Save((y) =>
                    {
                        CurrentStuff.StuffItems.Reload(IdeaBlade.EntityModel.MergeStrategy.OverwriteChanges);
                        callback(true);
                    }
                    );
                
            }
        }
Back to Top
JChris View Drop Down
Newbie
Newbie
Avatar

Joined: 13-Mar-2012
Location: Kansas
Posts: 8
Post Options Post Options   Quote JChris Quote  Post ReplyReply Direct Link To This Post Posted: 13-Apr-2012 at 8:04am
I notice that CanClose() is being called twice, even in the simplest CanClose() method, like the one mentioned above. Can you elucidate?
Back to Top
 Post Reply Post Reply Page  12>

Forum Jump Forum Permissions View Drop Down