Page Index Toggle Pages: 1 Send TopicPrint
Normal Topic Context menu for appointments (Read 7936 times)
gerardo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 27
Joined: Jan 26th, 2007
Context menu for appointments
Feb 1st, 2007 at 7:53pm
Print Post  
I need to display a context menu whose options are related with the appointment.

I started using the context menu from the calendar and updating this according to the selected appointment. However if the user hold the stylus again an appointment the context menu is displayed but the appointment is not selected, so I can't update the options for the context menu.

Has anybody work with a similar situation before? or has an idea to resolve this issue?

Thanks in advance
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Context menu for appointments
Reply #1 - Feb 2nd, 2007 at 6:37am
Print Post  
You can handle the Calendar.ItemClick event and display the context menu in the event handler. There you can obtain a reference to the clicked item through the event arguments passed to the event handler and adjust the options in the context menu accordingly. You can also select the item in the event handler by adding it to the Calendar.ItemSelection object.

Meppy
  
Back to top
 
IP Logged
 
gerardo
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 27
Joined: Jan 26th, 2007
Re: Context menu for appointments
Reply #2 - Feb 2nd, 2007 at 2:02pm
Print Post  
That is what I'm doing if the user just click the appointment.

However the case is different if you hold the stylus again the appintment for several seconds, in this case the item click event is not fired.

This is a common behavior on the PPC where the user try work with the context menu of the object that is being "hold" with the stylus.
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Context menu for appointments
Reply #3 - Feb 5th, 2007 at 7:13am
Print Post  
It seems that .NET Framework does not provide built-in support for stylus "hold-down" other than associating a context menu with a control, which menu gets displayed when the stylus is pressed and hold over the control. This action however doesn't really count as a mouse action as it seems. The control itself is never notified of this action and the Calendar events are not fired as a result.

The following scenario supplies a workaround for this limiation and provides you with the ability to control whether and when to display the context menu.

1. Create a timer object (make it a member of the form, which contains the Calendar control).

Code
Select All
private Timer timer;
// ...

// Somewhere during initialization
timer = new Timer();
timer.Interval  = 500;
timer.Enabled = false;
timer.Tick += new EventHandler(OnTick); 



2. Declare another member variable of type Point. We will use this variable to store the position of the mouse when the user initiates a click within the control.

Code
Select All
private Point mouse; 



3. Handle the MouseDown, MouseMove and MouseUp events of the Calendar control. The following source code illustrates the contents of each of the event handlers.

MouseDown handler contents:
Code
Select All
// Remember the mouse position
mouse = new Point(e.X, e.Y);

// Start the timer
timer.Enabled = true; 



MouseMove handler contents:
Code
Select All
// Since the user has moved the mouse, we can
// assume it is not a "hold-down" action.
// Stop the timer then
timer.Enabled = false; 



MouseUp handler contents:
Code
Select All
// Stop the timer as well
timer.Enabled = false; 



Implement the Timer.Tick event handler. The event handler should be invoked 0.5s after the timer has been started, i.e. 0.5s after the user has pressed the stylus, holding it down without moving it. We presume that the 'calendar' variable identifies the PocketPlanner instance and that there is a context menu referenced by the 'contextMenu' variable.

Code
Select All
private void OnTick(object sender, EventArgs e)
{
    // Stop the timer (to avoid this event being raised more than once)
    timer.Enabled = false;

    // Cancel the current drag operation within the Calendar
    calendar.ResetDrag();

    // Make any necessary checks here. For example
    // you can check whether the mouse is positioned
    // over an item by calling Calendar.GetItemAt and
    // passing 'mouse' to it. You can enable or disable
    // various items in the context menu as a result of the checks here

    // Finally display the context menu
    contextMenu.Show(calendar, mouse);
} 



I hope this helps.

Meppy
« Last Edit: Mar 16th, 2007 at 11:19am by Meppy »  
Back to top
 
IP Logged
 
Jeffry
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 26
Joined: Feb 9th, 2007
Re: Context menu for appointments
Reply #4 - Mar 16th, 2007 at 10:49am
Print Post  
I had the same problem and this seems to work. However, how does it see now that I'm trying to do a normal click?

A normal click should open the appointment and a "hold-down" click should show the contextmenu.

I'll see if I can come up with something, but if anyone has any bright ideas, please let me know  Smiley
  
Back to top
 
IP Logged
 
Meppy
God Member
*****
Offline


MindFusion support

Posts: 1783
Joined: Jul 20th, 2005
Re: Context menu for appointments
Reply #5 - Mar 16th, 2007 at 11:27am
Print Post  
Just handle the Calendar.ItemClick event as you would do normally and disable the timer right away to prevent the timer's event handler from being invoked. Like this:

Code
Select All
timer.Enabled = false; 


Then continue processing the ItemClick event handler the normal way without worrying about context menus.

Meppy

P.S.: There were some mistakes in my previous post above that were fixed.
  
Back to top
 
IP Logged
 
Jeffry
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 26
Joined: Feb 9th, 2007
Re: Context menu for appointments
Reply #6 - Mar 17th, 2007 at 12:02pm
Print Post  
The problem is that the ItemClick event is fired even if the styles is hold-down.
  
Back to top
 
IP Logged
 
Jeffry
YaBB Newbies
*
Offline


I love YaBB 1G - SP1!

Posts: 26
Joined: Feb 9th, 2007
Re: Context menu for appointments
Reply #7 - Mar 17th, 2007 at 12:35pm
Print Post  
Ok, fixed it using the calendar.Click event instead of the ItemClick. This event doesn't fire on a hold-down.

Then in the Click event I use the GetItemAt() to check if an item is clicked.
  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint