Skip to content

Commit

Permalink
Added alt+arrow reorder of bookmarks
Browse files Browse the repository at this point in the history
fixed #1309
  • Loading branch information
vchelaru committed Dec 22, 2023
1 parent 1859899 commit 3f0cebd
Show file tree
Hide file tree
Showing 6 changed files with 716 additions and 625 deletions.
20 changes: 12 additions & 8 deletions FRBDK/Glue/Glue/Controls/MainPanelControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,20 @@ private void InitializeThemes()

private void UserControl_PreviewKeyDown(object sender, KeyEventArgs e)
{
// If this is coming from a text box, don't try to apply hotkeys
// Maybe in the future we want to be selective, like only apply certain
// hotkeys (ctrl+f) but not others (delete)?
var isTextBox = e.OriginalSource is TextBoxBase;
var handledByPlugin = PluginManager.IsHandlingHotkeys();
if (!handledByPlugin)
{
// If this is coming from a text box, don't try to apply hotkeys
// Maybe in the future we want to be selective, like only apply certain
// hotkeys (ctrl+f) but not others (delete)?
var isTextBox = e.OriginalSource is TextBoxBase;

var isHandled = HotkeyManager.Self.TryHandleKeys(e, isTextBox).Result;
var isHandled = HotkeyManager.Self.TryHandleKeys(e, isTextBox).Result;

if (isHandled)
{
e.Handled = true;
if (isHandled)
{
e.Handled = true;
}
}
}

Expand Down
6 changes: 6 additions & 0 deletions FRBDK/Glue/Glue/Plugins/PluginBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,12 @@ protected async Task<string> ReactToPluginEventWithReturn(string eventName, stri
/// </summary>
public Func<object, int, int, Task> ReactToObjectReordered;

/// <summary>
/// Raised to determine if a plugin should handle a hotkey. A plugin should return true if it has its own hotkey handling given
/// its current state, such as if a control has focus.
/// </summary>
public Func<bool> IsHandlingHotkeys;

#endregion

public abstract void StartUp();
Expand Down
23 changes: 20 additions & 3 deletions FRBDK/Glue/Glue/Plugins/PluginManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,23 @@ public static void ReactToNewObject(NamedObjectSave newObject) =>
plugin => plugin.ReactToNewObjectHandler(newObject),
plugin => plugin.ReactToNewObjectHandler != null);

internal static bool IsHandlingHotkeys()
{
var toReturn = false;

CallMethodOnPlugin(
plugin =>
{
if(toReturn == false && plugin.IsHandlingHotkeys())
{
toReturn = true;
}
},
plugin => plugin.IsHandlingHotkeys != null);

return toReturn;
}

public static Task ReactToNewObjectListAsync(List<NamedObjectSave> newObjectList)
{
return CallMethodOnPluginAsync(async (plugin) =>
Expand Down Expand Up @@ -1029,12 +1046,11 @@ public static Task ReactToNewObjectListAsync(List<NamedObjectSave> newObjectList
plugin => plugin.ReactToNewObjectHandler != null || plugin.ReactToNewObjectList != null || plugin.ReactToNewObjectListAsync != null);
}

internal static void ReactToObjectRemoved(IElement element, NamedObjectSave removedObject)
{
internal static void ReactToObjectRemoved(IElement element, NamedObjectSave removedObject) =>
CallMethodOnPlugin(
plugin => plugin.ReactToObjectRemoved(element, removedObject),
plugin => plugin.ReactToObjectRemoved != null);
}


public static void TryAssignPreferredDisplayerFromName(CustomVariable customVariable)
{
Expand Down Expand Up @@ -2498,5 +2514,6 @@ static void ResumeRelativeDirectory(string function)
}
}


}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ class MainTreeViewPlugin : PluginBase

#endregion

public override bool ShutDown(PluginShutDownReason shutDownReason)
{
return true;
}

public override void StartUp()
{
var pixelHeight = GlueState.Self.GlueSettingsSave.BookmarkRowHeight > 0
Expand Down Expand Up @@ -106,6 +101,7 @@ private void AssignEvents()
ReactToCtrlF += HandleCtrlF;
ReactToItemsSelected += HandleItemsSelected;
TryHandleTreeNodeDoubleClicked += TryHandleTreeNodeDoubleClick;
IsHandlingHotkeys += () => mainView.Bookmarks.IsFocused || mainView.Bookmarks.IsKeyboardFocusWithin;
}

private bool TryHandleTreeNodeDoubleClick(ITreeNode arg)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
Drop="Bookmarks_Drop"
SelectionChanged="Bookmarks_SelectionChanged"
KeyDown="Bookmarks_KeyDown"
PreviewKeyDown="Bookmarks_PreviewKeyDown"
LostFocus="Bookmarks_LostFocus"
MouseDoubleClick="Bookmarks_MouseDoubleClick"
ItemsSource="{Binding Bookmarks}"
Expand Down
Loading

0 comments on commit 3f0cebd

Please sign in to comment.