mirror of
https://gitlab.com/cc-ru/ocelot/ocelot-desktop.git
synced 2025-12-20 02:59:19 +01:00
Intercept mouse press events when dragging scroll bar thumbs
This commit is contained in:
parent
87b13e66b1
commit
1c74adc329
@ -7,7 +7,6 @@ import ocelot.desktop.graphics.Graphics
|
|||||||
import ocelot.desktop.ui.event.handlers.HoverHandler
|
import ocelot.desktop.ui.event.handlers.HoverHandler
|
||||||
import ocelot.desktop.ui.event.sources.{BrainEvents, KeyEvents, MouseEvents, ScrollEvents}
|
import ocelot.desktop.ui.event.sources.{BrainEvents, KeyEvents, MouseEvents, ScrollEvents}
|
||||||
import ocelot.desktop.ui.event.{Capturing, CapturingEvent, Dispatchable, MouseEvent}
|
import ocelot.desktop.ui.event.{Capturing, CapturingEvent, Dispatchable, MouseEvent}
|
||||||
import ocelot.desktop.ui.widget.window.Window
|
|
||||||
import ocelot.desktop.ui.widget.{RootWidget, Widget}
|
import ocelot.desktop.ui.widget.{RootWidget, Widget}
|
||||||
import ocelot.desktop.util._
|
import ocelot.desktop.util._
|
||||||
import ocelot.desktop.{OcelotDesktop, Settings}
|
import ocelot.desktop.{OcelotDesktop, Settings}
|
||||||
@ -24,7 +23,6 @@ import java.nio.channels.Channels
|
|||||||
import java.nio.file.Paths
|
import java.nio.file.Paths
|
||||||
import javax.imageio.ImageIO
|
import javax.imageio.ImageIO
|
||||||
import javax.swing.JFileChooser
|
import javax.swing.JFileChooser
|
||||||
import scala.annotation.tailrec
|
|
||||||
import scala.collection.mutable
|
import scala.collection.mutable
|
||||||
import scala.collection.mutable.ArrayBuffer
|
import scala.collection.mutable.ArrayBuffer
|
||||||
import scala.concurrent.duration.DurationInt
|
import scala.concurrent.duration.DurationInt
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import ocelot.desktop.graphics.Graphics
|
|||||||
import ocelot.desktop.ui.UiHandler
|
import ocelot.desktop.ui.UiHandler
|
||||||
import ocelot.desktop.ui.event.handlers.HoverHandler
|
import ocelot.desktop.ui.event.handlers.HoverHandler
|
||||||
import ocelot.desktop.ui.event.sources.KeyEvents
|
import ocelot.desktop.ui.event.sources.KeyEvents
|
||||||
import ocelot.desktop.ui.event.{MouseEvent, ScrollEvent}
|
import ocelot.desktop.ui.event.{Capturing, MouseEvent, ScrollEvent}
|
||||||
import ocelot.desktop.ui.layout.Layout
|
import ocelot.desktop.ui.layout.Layout
|
||||||
import ocelot.desktop.ui.widget.ScrollView.{DecayFactor, DragState, MaxScrollVelocity, MinThumbSize, ScrollVelocity}
|
import ocelot.desktop.ui.widget.ScrollView.{DecayFactor, DragState, MaxScrollVelocity, MinThumbSize, ScrollVelocity}
|
||||||
import ocelot.desktop.util.Logging
|
import ocelot.desktop.util.Logging
|
||||||
@ -49,10 +49,15 @@ class ScrollView(val inner: Widget) extends Widget with Logging with HoverHandle
|
|||||||
scrollToEnd = false
|
scrollToEnd = false
|
||||||
}
|
}
|
||||||
|
|
||||||
case MouseEvent(MouseEvent.State.Pressed, MouseEvent.Button.Left) =>
|
case Capturing(event @ MouseEvent(MouseEvent.State.Pressed, MouseEvent.Button.Left)) =>
|
||||||
val pos = UiHandler.mousePosition
|
val pos = UiHandler.mousePosition
|
||||||
|
|
||||||
|
if (vThumbBounds.contains(pos) || hThumbBounds.contains(pos)) {
|
||||||
|
event.consume()
|
||||||
|
}
|
||||||
|
|
||||||
dragState = if (vThumbBounds.contains(pos)) {
|
dragState = if (vThumbBounds.contains(pos)) {
|
||||||
|
scrollToEnd = false
|
||||||
DragState.Vertical(yOffset, pos)
|
DragState.Vertical(yOffset, pos)
|
||||||
} else if (hThumbBounds.contains(pos)) {
|
} else if (hThumbBounds.contains(pos)) {
|
||||||
DragState.Horizontal(xOffset, pos)
|
DragState.Horizontal(xOffset, pos)
|
||||||
@ -60,10 +65,6 @@ class ScrollView(val inner: Widget) extends Widget with Logging with HoverHandle
|
|||||||
DragState.None
|
DragState.None
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dragState.isVertical) {
|
|
||||||
scrollToEnd = false
|
|
||||||
}
|
|
||||||
|
|
||||||
case MouseEvent(MouseEvent.State.Released, MouseEvent.Button.Left) =>
|
case MouseEvent(MouseEvent.State.Released, MouseEvent.Button.Left) =>
|
||||||
dragState = DragState.None
|
dragState = DragState.None
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user