@@ -47,6 +47,11 @@ namespace FlaxEditor.GUI.ContextMenu
|
||||
private Window _window;
|
||||
private Control _previouslyFocused;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether use automatic popup direction fix based on the screen dimensions.
|
||||
/// </summary>
|
||||
protected virtual bool UseAutomaticDirectionFix => true;
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if context menu is opened
|
||||
/// </summary>
|
||||
@@ -132,21 +137,24 @@ namespace FlaxEditor.GUI.ContextMenu
|
||||
Rectangle monitorBounds = Platform.GetMonitorBounds(locationSS);
|
||||
Vector2 rightBottomLocationSS = locationSS + dpiSize;
|
||||
bool isUp = false, isLeft = false;
|
||||
if (monitorBounds.Bottom < rightBottomLocationSS.Y)
|
||||
if (UseAutomaticDirectionFix)
|
||||
{
|
||||
// Direction: up
|
||||
isUp = true;
|
||||
locationSS.Y -= dpiSize.Y;
|
||||
if (monitorBounds.Bottom < rightBottomLocationSS.Y)
|
||||
{
|
||||
// Direction: up
|
||||
isUp = true;
|
||||
locationSS.Y -= dpiSize.Y;
|
||||
|
||||
// Offset to fix sub-menu location
|
||||
if (parent is ContextMenu menu && menu._childCM != null)
|
||||
locationSS.Y += 30.0f * dpiScale;
|
||||
}
|
||||
if (monitorBounds.Right < rightBottomLocationSS.X)
|
||||
{
|
||||
// Direction: left
|
||||
isLeft = true;
|
||||
locationSS.X -= dpiSize.X;
|
||||
// Offset to fix sub-menu location
|
||||
if (parent is ContextMenu menu && menu._childCM != null)
|
||||
locationSS.Y += 30.0f * dpiScale;
|
||||
}
|
||||
if (monitorBounds.Right < rightBottomLocationSS.X)
|
||||
{
|
||||
// Direction: left
|
||||
isLeft = true;
|
||||
locationSS.X -= dpiSize.X;
|
||||
}
|
||||
}
|
||||
|
||||
// Update direction flag
|
||||
|
||||
@@ -42,9 +42,6 @@ namespace FlaxEditor.GUI
|
||||
/// <summary>
|
||||
/// Gets or sets the initial value.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The initial value.
|
||||
/// </value>
|
||||
public string InitialValue
|
||||
{
|
||||
get => _startValue;
|
||||
@@ -54,9 +51,6 @@ namespace FlaxEditor.GUI
|
||||
/// <summary>
|
||||
/// Gets or sets the input field text.
|
||||
/// </summary>
|
||||
/// <value>
|
||||
/// The text.
|
||||
/// </value>
|
||||
public string Text
|
||||
{
|
||||
get => _inputField.Text;
|
||||
@@ -138,6 +132,9 @@ namespace FlaxEditor.GUI
|
||||
Hide();
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override bool UseAutomaticDirectionFix => false;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override bool OnKeyDown(KeyboardKeys key)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user