mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Fix hit testing of text layers.
This commit is contained in:
parent
575de76a43
commit
2f7880af8e
1 changed files with 14 additions and 0 deletions
|
@ -642,10 +642,24 @@ public class ImageEditorCanvasView: UIView {
|
|||
guard let sublayers = contentView.layer.sublayers else {
|
||||
return nil
|
||||
}
|
||||
|
||||
// First we build a map of all text layers.
|
||||
var layerMap = [String: EditorTextLayer]()
|
||||
for layer in sublayers {
|
||||
guard let textLayer = layer as? EditorTextLayer else {
|
||||
continue
|
||||
}
|
||||
layerMap[textLayer.itemId] = textLayer
|
||||
}
|
||||
|
||||
// The layer ordering in the model is authoritative.
|
||||
// Iterate over the layers in _reverse_ order of which they appear
|
||||
// in the model, so that layers "on top" are hit first.
|
||||
for item in model.items().reversed() {
|
||||
guard let textLayer = layerMap[item.itemId] else {
|
||||
// Not a text layer.
|
||||
continue
|
||||
}
|
||||
if textLayer.hitTest(point) != nil {
|
||||
return textLayer
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue