This Question is Answered

15 "helpful" answers available (3 pts)
6 Replies Last post: Jul 8, 2008 10:06 PM by varshuj

Regarding CalendarControl

Jul 7, 2008 6:58 AM

Click to view varshuj's profile Level 3 varshuj 51 posts since
Mar 6, 2008

Hello,

On valuefinished event of CalendarControl im getting some value but getting null value on right click event.

How can i get the date on which right click event is being fired?


Thanks,

Varsha

Click to view Kamal's profile Curl Kamal 149 posts since
Oct 17, 2007
1. Re: Regarding CalendarControl Jul 7, 2008 8:23 AM
How do you get "null" on a right-click event?

The default implementation of the CallendarControlUI uses left clicks to change the value of the calendar control.
Do you have your own implementation of the CalendarControlUI?
Click to view varshuj's profile Level 3 varshuj 51 posts since
Mar 6, 2008
2. Re: Regarding CalendarControl Jul 7, 2008 9:05 PM
in response to: Kamal

Actually left-click on CalendarControl changes the value of the calendar control.

but right click will display the previous set value and it doesnt changes the value of calendar control on right click.


Thanks

Varsha

Click to view Kamal's profile Curl Kamal 149 posts since
Oct 17, 2007
3. Re: Regarding CalendarControl Jul 8, 2008 6:01 AM
in response to: varshuj
I am sorry. I am still not clear about what you are asking about.

The default behavior of the CalendarControl should not do anything when right click. When you mouse over a day cell, it highlights the cell with a dotted border to indicate the day that will be selected if you left click on it.

Are you sub classing the UI to extend the feature so that the right click shows the previous set value? And how does it display the previous set value?

Thanks,
Kamal
Click to view varshuj's profile Level 3 varshuj 51 posts since
Mar 6, 2008
4. Re: Regarding CalendarControl Jul 8, 2008 6:45 AM
in response to: Kamal

Hi kamal,

I m sorry for not elaborating the question,Actually i want to show one contextmenu over right click which contains menuaction to select date value (Calendar cell) . So when I click on the this menuaction it should return me the currently highlighted cell's value i.e date value.Generally we get the date value on single left click .This functionality or default behavior i want for right click.Isthere any way to do this by subclassing or any other way.

following is reference code explaining my problem:

{CalendarControl
{context-popup
menu-pane = {MenuPane
{MenuAction label ="select current Date",
{on Action at mc:MenuAction do
{popup-message "I want date value here " }
}
}

}
}
}


Thanks

Varsha

Click to view Kamal's profile Curl Kamal 149 posts since
Oct 17, 2007
5. Re: Regarding CalendarControl Jul 8, 2008 7:52 AM
in response to: varshuj
There are two approaches to fix this. The better solution will be to subclass the UI. Unfortunately the UI that is used for displaying the Day is not public. However all the source code is open so you can use the open source to change the UI as you want.

However you can use one of these two approaches. Both of these use the fact that you can provide your own Graphic to display as a Day number.

Note that in the first approach, one right clicking on top of the number is going to work.


{CalendarControl
    day-proc =
        {proc {cc:CalendarControl, date:DateTime}:(#Graphic, bool)
            let constant info:DateTimeInfo = date.info
            {return
                {Frame
                    opaque-to-events? = true,
                    {value info.day},
                     {context-popup
                         menu-pane =
                             {MenuPane
                                 {MenuAction label ="select current Date",
                                     {on Action at mc:MenuAction do
                                         {popup-message "The date is " & date   }
                                     }
                                 }    
                             }
                     }
                },
                true
            }
        },
    {on e:ContextMenuEvent do
        {e.consume}
    }
}
 


In the second approach, I am adding these event handlers to the parent of my day graphic. This may not work for all the UIs. It is assuming that all the day Graphics are inside another graphic that contains a single day. By doing this now you can click anywhere in the parent cell of the day.


{CalendarControl
    day-proc =
        {proc {cc:CalendarControl, date:DateTime}:(#Graphic, bool)
            let constant info:DateTimeInfo = date.info
            {return
                {Frame
                    opaque-to-events? = true,
                    {value info.day},
                    {on e:AttachEvent at frm:Frame do
                        def parent = frm.parent
                        def context-handler =
                            {on e:ContextMenuEvent at df:Graphic do
                                {if e.consumed? then {return}}
                                
                                {e.consume}
                                {{MenuPane
                                    {MenuAction label ="select current Date",
                                        {on Action at mc:MenuAction do
                                            {popup-message "The date is " & date   }
                                        }
                                    }    
                                 }.popup df, e.x, e.y}
                            }
                        {parent.add-event-handler context-handler}
                        {frm.add-event-handler
                            {on e:DetachEvent at outer-frame:Frame do
                                {parent.remove-event-handler context-handler}
                            }
                        }
                    }
                },
                true
            }
        },
    {on e:ContextMenuEvent do
        {e.consume}
    }
}
 
Click to view varshuj's profile Level 3 varshuj 51 posts since
Mar 6, 2008
6. Re: Regarding CalendarControl Jul 8, 2008 10:06 PM
in response to: Kamal

Thanks a lot kamal i got the solution.

varsha