mirror of
https://github.com/fjvallarino/monomer.git
synced 2024-09-20 08:17:37 +03:00
Fix textArea text cases
This commit is contained in:
parent
4fcfbc3147
commit
ff3d7da5b8
@ -245,7 +245,7 @@ data ScrollContext = ScrollContext {
|
||||
vScrollRect :: Rect,
|
||||
hThumbRect :: Rect,
|
||||
vThumbRect :: Rect
|
||||
}
|
||||
} deriving (Eq, Show)
|
||||
|
||||
instance Default ScrollState where
|
||||
def = ScrollState {
|
||||
@ -335,18 +335,16 @@ makeScroll config state = widget where
|
||||
newNode = node
|
||||
& L.widget .~ makeScroll config oldState
|
||||
|
||||
findByPoint wenv node start point
|
||||
| not mouseInScroll && (childHovered || childDragged) = Just 0
|
||||
| otherwise = Nothing
|
||||
where
|
||||
sctx = scrollStatus config wenv node state point
|
||||
mouseInScroll = hMouseInScroll sctx || vMouseInScroll sctx
|
||||
realPoint = addPoint point offset
|
||||
child = Seq.index (node ^. L.children) 0
|
||||
childHovered = isPointInNodeVp realPoint child
|
||||
childDragged = case wenv ^. L.mainBtnPress of
|
||||
Just (path, _) -> isNodeParentOfPath path child
|
||||
Nothing -> False
|
||||
findByPoint wenv node start point = result where
|
||||
sctx = scrollStatus config wenv node state point
|
||||
mouseInScroll = hMouseInScroll sctx || vMouseInScroll sctx
|
||||
childPoint = addPoint point offset
|
||||
child = Seq.index (node ^. L.children) 0
|
||||
childHovered = isPointInNodeVp childPoint child
|
||||
childDragged = isNodePressed wenv child
|
||||
result
|
||||
| (not mouseInScroll && childHovered) || childDragged = Just 0
|
||||
| otherwise = Nothing
|
||||
|
||||
handleEvent wenv node target evt = case evt of
|
||||
Focus{} -> result where
|
||||
|
@ -200,19 +200,19 @@ handleEventMouseSelect = describe "handleEventMouseSelect" $ do
|
||||
model steps ^. textValue `shouldBe` "This is text!"
|
||||
|
||||
it "should drag around and input 'Text'" $ do
|
||||
let str = ""
|
||||
let str = "This is random"
|
||||
let selStart = Point 50 10
|
||||
let selMid1 = Point 0 10
|
||||
let selMid2 = Point 200 10
|
||||
let selMid3 = Point (-200) 10
|
||||
let selEnd = Point 120 10
|
||||
let selEnd = Point 150 10
|
||||
let moves = [evtMove selMid1, evtMove selMid2, evtMove selMid3, evtMove selEnd]
|
||||
let steps = [evtT str, evtPress selStart] ++ moves ++ [evtRelease selEnd, evtT "Text"]
|
||||
model steps ^. textValue `shouldBe` "Text"
|
||||
model steps ^. textValue `shouldBe` "This Text"
|
||||
|
||||
it "should input 'This is text', select 'is text' and input 'test'" $ do
|
||||
let str = "This is text"
|
||||
let selStart = Point 40 10
|
||||
let selStart = Point 50 10
|
||||
let selEnd = Point 120 10
|
||||
let steps = [evtT str, evtPress selStart, evtMove selEnd, evtRelease selEnd, evtT "test"]
|
||||
model steps ^. textValue `shouldBe` "This test"
|
||||
@ -235,8 +235,7 @@ handleEventMouseSelect = describe "handleEventMouseSelect" $ do
|
||||
wenv = mockWenvEvtUnit (TestModel "")
|
||||
txtNode = vstack [
|
||||
hstack [
|
||||
textArea textValue `style` [width 105, height 20],
|
||||
hstack []
|
||||
textArea textValue `style` [height 50]
|
||||
]
|
||||
]
|
||||
model es = nodeHandleEventModel wenv es txtNode
|
||||
|
Loading…
Reference in New Issue
Block a user