This is a migrated thread and some comments may be shown as answers.

[Solved] Hold mouse state pressed while gridview lost focus

6 Answers 269 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Parking
Top achievements
Rank 1
Parking asked on 14 Oct 2010, 06:36 AM
hi, i found a strange scenerio as follow:
I handle  when the left mouse button is pressed on gridview and do some things make the gridview lost focus, such as popup a childwindow immediately, then gridview can't receive the left mouse button up event, when the gridview get focus, while the mouse state is Pressed makes behaviour strange.

i test the microsoft datagrid control, it seems clear the MouseState when gridview lost focus.

for now , i want the clear the Mouse state/ reset the mouse state to original while grid losting focus , just like microsoft datagrid.

thanks.

6 Answers, 1 is accepted

Sort by
0
Parking
Top achievements
Rank 1
answered on 14 Oct 2010, 11:31 AM
i found if you do any action take the radgridview lost focus, at follow timing:
MouseLeftButtonDown --> timing here -->MouseLeftButtonUp
you can easily do this:
Mouse.AddMouseDownHandler(this.GridView, new EventHandler<Telerik.Windows.Input.MouseButtonEventArgs>(MouseEventArgsHanderl), true);
 void MouseEventArgsHanderl(object sender, Telerik.Windows.Input.MouseButtonEventArgs e)
        {
           var state=e.ButtonState;  // break here by debuger. 
      // or pop a busyindicator take gridview lostf
}

and press f5 to continue, you will found the mouse's state hold pressed state. can any way i can clear the pressed state?
i found microsoft datagrid without this problem.
0
Tsvyatko
Telerik team
answered on 20 Oct 2010, 04:16 PM
Hi Parking,

I have prepared sample application that illustrates the described behavior using both the RadGridview as well as the DataGrid. However I am unable to get the behavior described earlier. Is it posssible to look at the example and let me know if the can be reproduced with the attached project.

Sincerely yours,
Tsvyatko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Parking
Top achievements
Rank 1
answered on 22 Oct 2010, 08:40 AM
thanks for your replay.
i am missing something,and both grid SelectionMode="Extended"  and the event handler as follow:
void MouseEventArgsHanderl(object sender, Telerik.Windows.Input.MouseButtonEventArgs e)
       {
           var state = e.ButtonState;
           MessageBox.Show("close me, and move mouse over grid.", "", MessageBoxButton.OK);
           // break here by debuger. 
           // or pop a busyindicator take gridview lostf
       }
close the messagebox, than move mouse over the grid, don't click.  the selection depends mouse moving!!   not Extended mode anymore,
and  i can't upload sample project files. i just  attach a picture.
i can send it by email to you if any email available.
0
yong kong
Top achievements
Rank 1
answered on 25 Oct 2010, 03:54 AM

 

Ok here is a small hack that should do the trick for you .

Before opening the popup messageBox set
RadGridView.CanUserSelect = false;

and after hiding the Messagebox
RadGridView.CanUserSelect = bool;

void MouseEventArgsHanderl(object sender,
                           Telerik.Windows.Input.MouseButtonEventArgs e)
{
    var state = e.ButtonState;
    SampleGrid.CanUserSelect = false;
    
    // break here by debuger. 
    // or pop a busyindicator take gridview lostf
    MessageBox.Show("close me, and move mouse over grid.",
                     
"", MessageBoxButton.OK);
   SampleGrid.CanUserSelect = true;
}

Does the new version will fix this bug?

0
yong kong
Top achievements
Rank 1
answered on 25 Oct 2010, 04:34 AM

1.Add "CanUserSelect" property in ViewModel

    public class MainViewModel : INotifyPropertyChanged
    {
        private bool _canUserSelect;
        public bool CanUserSelect
        {
            get {return _canUserSelect;}
            set
            {
                _canUserSelect = value;
                this.OnPropertyChanged("CanUserSelect");
            }
        }
         
        public MainViewModel()
        {
            GenerateData(100);
            CanUserSelect = true;
        }
 
               //Some other code
   
}

2.Bind "CanUserSelect" Propery on RadGridView

<telerik:RadGridView ItemsSource="{Binding Data}" x:Name="SampleGrid"
SelectionMode="Extended" CanUserSelect="{Binding CanUserSelect}">
</
telerik:RadGridView>

3.Change "CanUserSelect" Property when popup something(chidWindow,messageBox,busyindicator..)

void MouseEventArgsHanderl(object sender,
                           Telerik.Windows.Input.MouseButtonEventArgs e)
{
     var state = e.ButtonState;
     var viewModel=(MainViewModel) this.DataContext;
     viewModel.CanUserSelect = false;
    
    // break here by debuger. 
    // or pop a busyindicator take gridview lostf
    MessageBox.Show("close me, and move mouse over grid.", "", MessageBoxButton.OK);
    viewModel.CanUserSelect = true;
}
0
Parking
Top achievements
Rank 1
answered on 27 Oct 2010, 03:00 AM
yong kong, thanks for your great works, everything works fine, but i use the trick cause Ctrl & Shift Keys unselect  Invalid.
Tags
GridView
Asked by
Parking
Top achievements
Rank 1
Answers by
Parking
Top achievements
Rank 1
Tsvyatko
Telerik team
yong kong
Top achievements
Rank 1
Share this question
or