 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Jerry
Joined: 24 Jun 2004 Posts: 39
|
Posted: Sat Jun 04, 2005 3:37 am Post subject: New MonthCal feature |
|
|
I have this simple script below. And I can't figure out why
if I press the right or left arrow the script goes into a loop, however, if a date is selected it works ok.
Is this a bug or have I missed something.
| Code: | Gui, Add, MonthCal, gCalendar vmycalendar ,20050101
gui, show
return
Calendar:
gui, submit
msgbox, hello %mycalendar% |
|
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sat Jun 04, 2005 2:36 pm Post subject: |
|
|
Since GUI scripts are automatically persistent, you should use ExitApp to exit them. For example:
msgbox, hello %mycalendar%
ExitApp
Also, in this case there is no need to use "Gui Submit" unless you want to hide the window (for which "Gui Hide" would also work). This is because the control's associated variable (MyCalendar) is automatically updated with the selected date each time the g-label is launched. |
|
| Back to top |
|
 |
JBensimon
Joined: 16 Nov 2004 Posts: 130 Location: New York
|
Posted: Sat Jun 04, 2005 7:47 pm Post subject: Clarify? |
|
|
| Chris wrote: | | This is because the control's associated variable (MyCalendar) is automatically updated with the selected date each time the g-label is launched |
Can you please clarify this, Chris? Is it always the case that a control's associated variable is automatically updated whenever its g-label is launched, without the need for a Gui, Submit or a GuiControlGet? What about if the control doesn't have a g-label?
Thanks,
Jacques. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sat Jun 04, 2005 8:10 pm Post subject: Re: Clarify? |
|
|
| JBensimon wrote: | | Is it always the case that a control's associated variable is automatically updated whenever its g-label is launched, without the need for a Gui, Submit or a GuiControlGet? | No, only the ones that are specifically documented will do that (Slider, DateTime, MonthCal, Hotkey, Slider, Tab). For performance reasons, the others do not. For example, if an Edit control has a lot of text in it, there might be times when you would not want its variable updated for each launch of the g-label.
But you could argue that checkbox and radio should be changed to do this also. Although there is a slight chance it would break a few scripts, it might be worth it.
| Quote: | | What about if the control doesn't have a g-label? | You have to use "Gui Submit" or GuiControlGet in those cases. |
|
| Back to top |
|
 |
JBensimon
Joined: 16 Nov 2004 Posts: 130 Location: New York
|
Posted: Wed Jun 08, 2005 3:46 am Post subject: |
|
|
Another question I'd lost track of! Thanks for the clarification.
| Quote: | | But you could argue that checkbox and radio should be changed to do this also. Although there is a slight chance it would break a few scripts, it might be worth it. | I see the potential (small) extra convenience, but I suspect that more than a few scripts might get broken by the change in behavior (none of them mine, so this is purely speculative). For example, some programmers might for one reason or another have found it more convenient in some circumstances to work with a checkbox's previous (rather than new) state -- maybe because the 0 and 1 values worked out better in some expression -- and chosen to only update the associated variable at the end of the g-label processing.
Thanks again,
Jacques. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Wed Jun 08, 2005 5:20 pm Post subject: |
|
|
| JBensimon wrote: | | For example, some programmers might for one reason or another have found it more convenient in some circumstances to work with a checkbox's previous (rather than new) state | That's a very good reason not to change it. Thanks. |
|
| Back to top |
|
 |
guivho
Joined: 04 Jun 2005 Posts: 26 Location: Lokeren, Belgium
|
Posted: Thu Jun 09, 2005 9:14 pm Post subject: Could this be a bug in MonthCal |
|
|
Chris,
I have been doing some tests and I have a couple of questions.
| Code: |
Gui, Add, MonthCal, gCalendar vmycalendar ,20050101
gui, show
return
Calendar:
msgbox, hello %mycalendar%
exitapp
|
This works fine when you select a date. To my surprise, if a click the left or right arrow, the Calendar routine is also fired. Specifically, when clicking the right arrow, it selects 20050201. What if I want to select another date, e.g. 20050223?
Could the following be a bug, or do I do something wrong?
| Code: |
Gui, Add, MonthCal, gCalendar vmycalendar ,20050101
gui, show
return
Calendar:
msgbox, hello %mycalendar%
return
|
If I select different dates in the displayed month, the date is shown, and the calendar just waits for the next click. However, if you click the e.g. the right arrow, the date is shown in the little message box. When I click the OK button, the calendar starts moving by itself: the right arrow seems to get stuck and the calendar keeps selecting the 1rst of the next month and so on... |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Fri Jun 10, 2005 5:07 pm Post subject: Re: Could this be a bug in MonthCal |
|
|
| guivho wrote: | | To my surprise, if a click the left or right arrow, the Calendar routine is also fired. Specifically, when clicking the right arrow, it selects 20050201. What if I want to select another date, e.g. 20050223? | This behavior appears to be built into the control, so I think it's normal.
| Quote: | | ... if you click the e.g. the right arrow, the date is shown in the little message box. When I click the OK button, the calendar starts moving by itself: the right arrow seems to get stuck and the calendar keeps selecting the 1rst of the next month and so on... | I think this and other related bugs have been fixed in today's update. Thanks for reporting it. |
|
| Back to top |
|
 |
guivho
Joined: 04 Jun 2005 Posts: 26 Location: Lokeren, Belgium
|
Posted: Fri Jun 10, 2005 7:14 pm Post subject: |
|
|
Chris,
The running-wild problem is fixed. When clicking the left or right month selection arrow, the gCalendar label is only triggered once.
| Quote: | | Specifically, when clicking the right arrow, it selects 20050201. What if I want to select another date, e.g. 20050223? |
As it stands now, the script has no way of finding out whether the user really wanted to select 20050201, or whether the user will want to select another day in this month. Or maybe the user wants to get into june?
One possible approach would be to not preselect a date when changing months. So the gCalendar label would not be triggered. And the user could happily move around until the desired date is displayed. At that point the user would select a date within that month, and that would trigger the label.
Just my 2 cents,
guivho. |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10467
|
Posted: Sat Jun 11, 2005 11:20 am Post subject: |
|
|
| guivho wrote: | | One possible approach would be to not preselect a date when changing months. So the gCalendar label would not be triggered. | Unfortunately, that's the built-in behavior of the control. Although the control could be changed, it would likely be difficult.
| Quote: | | At that point the user would select a date within that month, and that would trigger the label. | The AltSubmit option has been revised to be of possible use here. If you specify AltSubmit, your g-label can check if A_GuiControlEvent = 1. If it is, the user explicitly clicked a date.
Even so, this might fall short of what you need because the date in the control still changes when navigating from month to month. But it might be worth some experimenting. |
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|