mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added a callback method to FileBrowserListener.
This commit is contained in:
parent
172d2a1c8b
commit
89455b18cb
9 changed files with 76 additions and 88 deletions
|
|
@ -2294,32 +2294,32 @@ private:
|
|||
uint8 componentTransparency;
|
||||
|
||||
//==============================================================================
|
||||
void internalMouseEnter (MouseInputSource& source, const Point<int>& relativePos, const Time& time);
|
||||
void internalMouseExit (MouseInputSource& source, const Point<int>& relativePos, const Time& time);
|
||||
void internalMouseDown (MouseInputSource& source, const Point<int>& relativePos, const Time& time);
|
||||
void internalMouseUp (MouseInputSource& source, const Point<int>& relativePos, const Time& time, const ModifierKeys& oldModifiers);
|
||||
void internalMouseDrag (MouseInputSource& source, const Point<int>& relativePos, const Time& time);
|
||||
void internalMouseMove (MouseInputSource& source, const Point<int>& relativePos, const Time& time);
|
||||
void internalMouseWheel (MouseInputSource& source, const Point<int>& relativePos, const Time& time, float amountX, float amountY);
|
||||
void internalMouseEnter (MouseInputSource&, const Point<int>&, const Time&);
|
||||
void internalMouseExit (MouseInputSource&, const Point<int>&, const Time&);
|
||||
void internalMouseDown (MouseInputSource&, const Point<int>&, const Time&);
|
||||
void internalMouseUp (MouseInputSource&, const Point<int>&, const Time&, const ModifierKeys& oldModifiers);
|
||||
void internalMouseDrag (MouseInputSource&, const Point<int>&, const Time&);
|
||||
void internalMouseMove (MouseInputSource&, const Point<int>&, const Time&);
|
||||
void internalMouseWheel (MouseInputSource&, const Point<int>&, const Time&, float amountX, float amountY);
|
||||
void internalBroughtToFront();
|
||||
void internalFocusGain (const FocusChangeType cause, const WeakReference<Component>&);
|
||||
void internalFocusGain (const FocusChangeType cause);
|
||||
void internalFocusLoss (const FocusChangeType cause);
|
||||
void internalChildFocusChange (FocusChangeType cause, const WeakReference<Component>&);
|
||||
void internalFocusGain (const FocusChangeType, const WeakReference<Component>&);
|
||||
void internalFocusGain (const FocusChangeType);
|
||||
void internalFocusLoss (const FocusChangeType);
|
||||
void internalChildFocusChange (FocusChangeType, const WeakReference<Component>&);
|
||||
void internalModalInputAttempt();
|
||||
void internalModifierKeysChanged();
|
||||
void internalChildrenChanged();
|
||||
void internalHierarchyChanged();
|
||||
Component* removeChildComponent (int index, bool sendParentEvents, bool sendChildEvents);
|
||||
void moveChildInternal (int sourceIndex, int destIndex);
|
||||
void paintComponentAndChildren (Graphics& g);
|
||||
void paintComponent (Graphics& g);
|
||||
void paintWithinParentContext (Graphics& g);
|
||||
void paintComponentAndChildren (Graphics&);
|
||||
void paintComponent (Graphics&);
|
||||
void paintWithinParentContext (Graphics&);
|
||||
void sendMovedResizedMessages (bool wasMoved, bool wasResized);
|
||||
void repaintParent();
|
||||
void sendFakeMouseMove() const;
|
||||
void takeKeyboardFocus (const FocusChangeType cause);
|
||||
void grabFocusInternal (const FocusChangeType cause, bool canTryParent = true);
|
||||
void takeKeyboardFocus (const FocusChangeType);
|
||||
void grabFocusInternal (const FocusChangeType, bool canTryParent = true);
|
||||
static void giveAwayFocus (bool sendFocusLossEvent);
|
||||
void sendEnablementChangeMessage();
|
||||
void sendVisibilityChangeMessage();
|
||||
|
|
|
|||
|
|
@ -391,13 +391,13 @@ private:
|
|||
|
||||
int getNumDisplayMonitors() const noexcept;
|
||||
const Rectangle<int> getDisplayMonitorCoordinates (int index, bool clippedToWorkArea) const noexcept;
|
||||
static void getCurrentMonitorPositions (Array <Rectangle<int> >& monitorCoords, const bool clipToWorkArea);
|
||||
static void getCurrentMonitorPositions (Array <Rectangle<int> >&, const bool clipToWorkArea);
|
||||
|
||||
void addDesktopComponent (Component* c);
|
||||
void removeDesktopComponent (Component* c);
|
||||
void componentBroughtToFront (Component* c);
|
||||
void addDesktopComponent (Component*);
|
||||
void removeDesktopComponent (Component*);
|
||||
void componentBroughtToFront (Component*);
|
||||
|
||||
static void setKioskComponent (Component* kioskModeComponent, bool enableOrDisable, bool allowMenusAndBars);
|
||||
static void setKioskComponent (Component*, bool enableOrDisable, bool allowMenusAndBars);
|
||||
|
||||
void triggerFocusCallback();
|
||||
void handleAsyncUpdate();
|
||||
|
|
|
|||
|
|
@ -139,9 +139,9 @@ private:
|
|||
friend class OwnedArray <ModalItem>;
|
||||
OwnedArray <ModalItem> stack;
|
||||
|
||||
void startModal (Component* component);
|
||||
void endModal (Component* component, int returnValue);
|
||||
void endModal (Component* component);
|
||||
void startModal (Component*);
|
||||
void endModal (Component*, int returnValue);
|
||||
void endModal (Component*);
|
||||
|
||||
JUCE_DECLARE_NON_COPYABLE (ModalComponentManager);
|
||||
};
|
||||
|
|
|
|||
|
|
@ -205,8 +205,11 @@ const File& FileBrowserComponent::getRoot() const
|
|||
|
||||
void FileBrowserComponent::setRoot (const File& newRootDirectory)
|
||||
{
|
||||
bool callListeners = false;
|
||||
|
||||
if (currentRoot != newRootDirectory)
|
||||
{
|
||||
callListeners = true;
|
||||
fileListComponent->scrollToTop();
|
||||
|
||||
String path (newRootDirectory.getFullPathName());
|
||||
|
|
@ -246,6 +249,12 @@ void FileBrowserComponent::setRoot (const File& newRootDirectory)
|
|||
|
||||
goUpButton->setEnabled (currentRoot.getParentDirectory().isDirectory()
|
||||
&& currentRoot.getParentDirectory() != currentRoot);
|
||||
|
||||
if (callListeners)
|
||||
{
|
||||
Component::BailOutChecker checker (this);
|
||||
listeners.callChecked (checker, &FileBrowserListener::browserRootChanged, currentRoot);
|
||||
}
|
||||
}
|
||||
|
||||
void FileBrowserComponent::resetRecentPaths()
|
||||
|
|
@ -367,6 +376,8 @@ void FileBrowserComponent::fileDoubleClicked (const File& f)
|
|||
}
|
||||
}
|
||||
|
||||
void FileBrowserComponent::browserRootChanged (const File&) {}
|
||||
|
||||
bool FileBrowserComponent::keyPressed (const KeyPress& key)
|
||||
{
|
||||
(void) key;
|
||||
|
|
|
|||
|
|
@ -177,27 +177,29 @@ public:
|
|||
/** @internal */
|
||||
void resized();
|
||||
/** @internal */
|
||||
void buttonClicked (Button* b);
|
||||
void buttonClicked (Button*);
|
||||
/** @internal */
|
||||
void comboBoxChanged (ComboBox*);
|
||||
/** @internal */
|
||||
void textEditorTextChanged (TextEditor& editor);
|
||||
void textEditorTextChanged (TextEditor&);
|
||||
/** @internal */
|
||||
void textEditorReturnKeyPressed (TextEditor& editor);
|
||||
void textEditorReturnKeyPressed (TextEditor&);
|
||||
/** @internal */
|
||||
void textEditorEscapeKeyPressed (TextEditor& editor);
|
||||
void textEditorEscapeKeyPressed (TextEditor&);
|
||||
/** @internal */
|
||||
void textEditorFocusLost (TextEditor& editor);
|
||||
void textEditorFocusLost (TextEditor&);
|
||||
/** @internal */
|
||||
bool keyPressed (const KeyPress& key);
|
||||
bool keyPressed (const KeyPress&);
|
||||
/** @internal */
|
||||
void selectionChanged();
|
||||
/** @internal */
|
||||
void fileClicked (const File& f, const MouseEvent& e);
|
||||
void fileClicked (const File&, const MouseEvent&);
|
||||
/** @internal */
|
||||
void fileDoubleClicked (const File& f);
|
||||
void fileDoubleClicked (const File&);
|
||||
/** @internal */
|
||||
bool isFileSuitable (const File& file) const;
|
||||
void browserRootChanged (const File&);
|
||||
/** @internal */
|
||||
bool isFileSuitable (const File&) const;
|
||||
/** @internal */
|
||||
bool isDirectorySuitable (const File&) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -51,6 +51,9 @@ public:
|
|||
|
||||
/** Callback when the user double-clicks on a file in the browser. */
|
||||
virtual void fileDoubleClicked (const File& file) = 0;
|
||||
|
||||
/** Callback when the browser's root folder changes. */
|
||||
virtual void browserRootChanged (const File& newRoot) = 0;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -190,16 +190,15 @@ void FileChooserDialogBox::selectionChanged()
|
|||
&& content->chooserComponent.getRoot().isDirectory());
|
||||
}
|
||||
|
||||
void FileChooserDialogBox::fileClicked (const File&, const MouseEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void FileChooserDialogBox::fileDoubleClicked (const File&)
|
||||
{
|
||||
selectionChanged();
|
||||
content->okButton.triggerClick();
|
||||
}
|
||||
|
||||
void FileChooserDialogBox::fileClicked (const File&, const MouseEvent&) {}
|
||||
void FileChooserDialogBox::browserRootChanged (const File&) {}
|
||||
|
||||
void FileChooserDialogBox::okToOverwriteFileCallback (int result, FileChooserDialogBox* box)
|
||||
{
|
||||
if (result != 0 && box != nullptr)
|
||||
|
|
|
|||
|
|
@ -138,15 +138,17 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** @internal */
|
||||
void buttonClicked (Button* button);
|
||||
void buttonClicked (Button*);
|
||||
/** @internal */
|
||||
void closeButtonPressed();
|
||||
/** @internal */
|
||||
void selectionChanged();
|
||||
/** @internal */
|
||||
void fileClicked (const File& file, const MouseEvent& e);
|
||||
void fileClicked (const File&, const MouseEvent&);
|
||||
/** @internal */
|
||||
void fileDoubleClicked (const File& file);
|
||||
void fileDoubleClicked (const File&);
|
||||
/** @internal */
|
||||
void browserRootChanged (const File&);
|
||||
|
||||
private:
|
||||
class ContentComponent;
|
||||
|
|
|
|||
|
|
@ -43,59 +43,33 @@ struct TextEditorKeyMapper
|
|||
*/
|
||||
static bool invokeKeyFunction (CallbackClass& target, const KeyPress& key)
|
||||
{
|
||||
const bool isShiftDown = key.getModifiers().isShiftDown();
|
||||
const bool isShiftDown = key.getModifiers().isShiftDown();
|
||||
const bool ctrlOrAltDown = key.getModifiers().isCtrlDown() || key.getModifiers().isAltDown();
|
||||
|
||||
if (key == KeyPress (KeyPress::downKey, ModifierKeys::ctrlModifier, 0)
|
||||
&& target.scrollUp())
|
||||
return true;
|
||||
|
||||
if (key == KeyPress (KeyPress::upKey, ModifierKeys::ctrlModifier, 0)
|
||||
&& target.scrollDown())
|
||||
return true;
|
||||
if (key == KeyPress (KeyPress::downKey, ModifierKeys::ctrlModifier, 0) && target.scrollUp()) return true;
|
||||
if (key == KeyPress (KeyPress::upKey, ModifierKeys::ctrlModifier, 0) && target.scrollDown()) return true;
|
||||
|
||||
#if JUCE_MAC
|
||||
if (key.getModifiers().isCommandDown())
|
||||
{
|
||||
if (key.isKeyCode (KeyPress::upKey))
|
||||
return target.moveCaretToTop (isShiftDown);
|
||||
|
||||
if (key.isKeyCode (KeyPress::downKey))
|
||||
return target.moveCaretToEnd (isShiftDown);
|
||||
|
||||
if (key.isKeyCode (KeyPress::leftKey))
|
||||
return target.moveCaretToStartOfLine (isShiftDown);
|
||||
|
||||
if (key.isKeyCode (KeyPress::rightKey))
|
||||
return target.moveCaretToEndOfLine (isShiftDown);
|
||||
if (key.isKeyCode (KeyPress::upKey)) return target.moveCaretToTop (isShiftDown);
|
||||
if (key.isKeyCode (KeyPress::downKey)) return target.moveCaretToEnd (isShiftDown);
|
||||
if (key.isKeyCode (KeyPress::leftKey)) return target.moveCaretToStartOfLine (isShiftDown);
|
||||
if (key.isKeyCode (KeyPress::rightKey)) return target.moveCaretToEndOfLine (isShiftDown);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (key.isKeyCode (KeyPress::upKey))
|
||||
return target.moveCaretUp (isShiftDown);
|
||||
if (key.isKeyCode (KeyPress::upKey)) return target.moveCaretUp (isShiftDown);
|
||||
if (key.isKeyCode (KeyPress::downKey)) return target.moveCaretDown (isShiftDown);
|
||||
if (key.isKeyCode (KeyPress::leftKey)) return target.moveCaretLeft (ctrlOrAltDown, isShiftDown);
|
||||
if (key.isKeyCode (KeyPress::rightKey)) return target.moveCaretRight (ctrlOrAltDown, isShiftDown);
|
||||
if (key.isKeyCode (KeyPress::pageUpKey)) return target.pageUp (isShiftDown);
|
||||
if (key.isKeyCode (KeyPress::pageDownKey)) return target.pageDown (isShiftDown);
|
||||
|
||||
if (key.isKeyCode (KeyPress::downKey))
|
||||
return target.moveCaretDown (isShiftDown);
|
||||
|
||||
if (key.isKeyCode (KeyPress::leftKey))
|
||||
return target.moveCaretLeft (ctrlOrAltDown, isShiftDown);
|
||||
|
||||
if (key.isKeyCode (KeyPress::rightKey))
|
||||
return target.moveCaretRight (ctrlOrAltDown, isShiftDown);
|
||||
|
||||
if (key.isKeyCode (KeyPress::pageUpKey))
|
||||
return target.pageUp (isShiftDown);
|
||||
|
||||
if (key.isKeyCode (KeyPress::pageDownKey))
|
||||
return target.pageDown (isShiftDown);
|
||||
|
||||
if (key.isKeyCode (KeyPress::homeKey))
|
||||
return ctrlOrAltDown ? target.moveCaretToTop (isShiftDown)
|
||||
: target.moveCaretToStartOfLine (isShiftDown);
|
||||
|
||||
if (key.isKeyCode (KeyPress::endKey))
|
||||
return ctrlOrAltDown ? target.moveCaretToEnd (isShiftDown)
|
||||
: target.moveCaretToEndOfLine (isShiftDown);
|
||||
if (key.isKeyCode (KeyPress::homeKey)) return ctrlOrAltDown ? target.moveCaretToTop (isShiftDown)
|
||||
: target.moveCaretToStartOfLine (isShiftDown);
|
||||
if (key.isKeyCode (KeyPress::endKey)) return ctrlOrAltDown ? target.moveCaretToEnd (isShiftDown)
|
||||
: target.moveCaretToEndOfLine (isShiftDown);
|
||||
|
||||
if (key == KeyPress ('c', ModifierKeys::commandModifier, 0)
|
||||
|| key == KeyPress (KeyPress::insertKey, ModifierKeys::ctrlModifier, 0))
|
||||
|
|
@ -109,11 +83,8 @@ struct TextEditorKeyMapper
|
|||
|| key == KeyPress (KeyPress::insertKey, ModifierKeys::shiftModifier, 0))
|
||||
return target.pasteFromClipboard();
|
||||
|
||||
if (key.isKeyCode (KeyPress::backspaceKey))
|
||||
return target.deleteBackwards (ctrlOrAltDown);
|
||||
|
||||
if (key.isKeyCode (KeyPress::deleteKey))
|
||||
return target.deleteForwards (ctrlOrAltDown);
|
||||
if (key.isKeyCode (KeyPress::backspaceKey)) return target.deleteBackwards (ctrlOrAltDown);
|
||||
if (key.isKeyCode (KeyPress::deleteKey)) return target.deleteForwards (ctrlOrAltDown);
|
||||
|
||||
if (key == KeyPress ('a', ModifierKeys::commandModifier, 0))
|
||||
return target.selectAll();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue