in reply to Re: Release Button in Click
in thread Release Button in Click

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re^3: Release Button in Click
by dasgar (Priest) on Sep 22, 2010 at 04:57 UTC

       What would be relevant code?

    You asked about buttons without telling us the context. You can use Perl to generate web pages, which can have buttons. You can use Perl to create a GUI based application using Tk. I think you get the point. Without understanding the context of what kind of button, it's difficult to understand how to help. Reverse the situation. If someone asked for help with a thingamajig, would you be able to offer help without knowing what the heck a thingamajig is?

    Based on your reference to loft.gld (presumably the GUI Loft) and 'Win32::GUI::Dialog', I think it's safe to assume that you're asking about buttons using Win32::GUI and you're using the GUI Loft.

    Ok, first I want to address using the GUI Loft. From personal experience, the code for the GUI Loft appears to use an older version of Win32::GUI than what is currently available. I primarily use the GUI Loft to help with sizing and location of each component and then use current documentation for the version of Win32::GUI that I'm using. It's still a useful tool, but keep in mind that it might be using deprecated syntax.

    To answer your question about the button, I'm referring to the ActivePerl User Guide to look at the documents for version 1.06 of Win32::GUI. If you're using a different distribution of Perl, you should be able to read the documentation that was included when Win32::GUI was installed. I would offer a link to CPAN, but I can't find the link for the detailed information for the button object.

    In your question, you asked about the Click event for the button object. For the functionality that you're looking for, I'd recommend looking into GotFocus, LostFocus and Push events. It sounds like the Push event may be what you're looking for.

    Since you're not inclined to make it clear what module that you're using or providing sample code that shows the problem you're encountering, I'm not inclined to crank out code to test the events listed above for you after trying to read your mind and providing this very detailed reply. I'm not trying to be mean, but you might want to check out the links in roboticus' reply. If you follow those links and apply that to your posts, I'm 100% sure that people would be much more willing to offer assistance.

      Yes, I should have given the Win32::GUI context ... eyes glazed over from lengthy fruitless search before finally posting this question resulted in tunnel vision. v1.06 of Win32::GUI is in use here as well, not the older version packaged with LOFT. I've used the ploy of creating an invisible dummyButton which gets clicked or pushed under program control at the end of the Click handler for the button I want to pop, but neither of those events do it; control transfers to dummyButton's handlers without any change in the visual appearance of either Button. And that makes sense to me (though I'd hoped for some luck) because the calls to dummyButton occur in the context of the handler of the Button I want to release. As for the code I'm not showing; that's exactly the problem. Suppose I take control of any event of any button; what code will then trigger redrawing of a button pushed? Short of looking into Win32 itself, I can't find anything in the Perl environment. I hope I'm getting this across more successfully now.

        It could be that the code in the event handler is taking a long time to complete, which means Win32::GUI won't have a chance to update the GUI, and the program will appear to hang. This includes redrawing controls. So if a lengthy piece of code is executed when a button is pressed, it will remain pressed until the code returns to the dialog loop. One solution to this problem is to periodically call Win32::GUI::DoEvents() in your code to allow Win32::GUI to process any pending events. Example:

        sub Button_Click { while(1){ # do something... Win32::GUI::DoEvents(); } return 1; }