Skip to content

Commit

Permalink
Mouse click cursor functions moved to common (#448)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdahlblom authored Jan 27, 2024
1 parent a4b10a7 commit ced0542
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 31 deletions.
15 changes: 14 additions & 1 deletion Source/ClassLibraryCommon/Common.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
namespace ClassLibraryCommon
using System.Windows.Input;

namespace ClassLibraryCommon
{
using NLog;
using System;
Expand Down Expand Up @@ -321,5 +323,16 @@ public static T FindVisualParent<T>(DependencyObject child) where T : Dependency
// here, To find the next parent in the tree. we are using recursion until we found the requested type or reached to the end of tree.
return FindVisualParent<T>(parentObj);
}

//^[A-Za-z0-9 . \t]*(MouseEnter){1}(\s\+\=)\s*
public static void UIElement_OnMouseEnterHandIcon(object sender, MouseEventArgs e)
{
Mouse.OverrideCursor = Cursors.Hand;
}

public static void UIElement_OnMouseLeaveNormalIcon(object sender, MouseEventArgs e)
{
Mouse.OverrideCursor = Cursors.Arrow;
}
}
}
33 changes: 3 additions & 30 deletions Source/ControlReference/Windows/LuaWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ private void LuaWindow_OnLoaded(object sender, RoutedEventArgs e)
}

var textBlock = new TextBlockSelectable(_luaCommand);
textBlock.MouseEnter += TextBlock_OnMouseEnter;
textBlock.MouseLeave += TextBlock_OnMouseLeave;
textBlock.MouseEnter += Common.UIElement_OnMouseEnterHandIcon;
textBlock.MouseLeave += Common.UIElement_OnMouseLeaveNormalIcon;
SetContextMenu(textBlock);

textBlock.FontFamily = new System.Windows.Media.FontFamily("Consolas");
Expand All @@ -71,34 +71,7 @@ private void LuaWindow_OnKeyDown(object sender, System.Windows.Input.KeyEventArg
{

}



private void TextBlock_OnMouseEnter(object sender, MouseEventArgs e)
{
try
{
Mouse.OverrideCursor = Cursors.IBeam;
}
catch (Exception exception)
{
Common.ShowMessageBox(exception.Message + Environment.NewLine + exception.StackTrace);
}
}

private void TextBlock_OnMouseLeave(object sender, MouseEventArgs e)
{
try
{
Mouse.OverrideCursor = Cursors.Arrow;
}
catch (Exception exception)
{
Common.ShowMessageBox(exception.Message + Environment.NewLine + exception.StackTrace);
}
}



private void SetContextMenu(TextBlockSelectable textBlock)
{
try
Expand Down

0 comments on commit ced0542

Please sign in to comment.