Skip to content

Commit

Permalink
fix copy and paste button, fix show multiple paste and title editor
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinBeBoy committed Mar 24, 2024
1 parent 579bc3f commit f7b5f22
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ui/cryptomaterial/editor.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func (t *Theme) Editor(editor *widget.Editor, hint string) Editor {
m := material.Editor(t.Base, editor, hint)
m.TextSize = t.TextSize
m.Color = t.Color.Text
m.Hint = hint
// m.Hint = hint
m.HintColor = t.Color.GrayText3

m0 := unit.Dp(0)
Expand Down Expand Up @@ -210,11 +210,14 @@ func (e *Editor) Layout(gtx C) D {
}

func (e *Editor) layout(gtx C) D {
if e.Editor.Len() > 0 {
e.LineColor, e.TitleLabel.Color = e.t.Color.Gray2, e.t.Color.GrayText3
if e.Editor.Len() > 0 && len(e.Hint) > 0 {
e.TitleLabel.Text = e.Hint
} else if e.Hint == "" {
e.Hint = e.TitleLabel.Text
e.TitleLabel.Text = ""
}

e.LineColor, e.TitleLabel.Color = e.t.Color.Gray2, e.t.Color.GrayText3
if e.Editor.Focused() {
e.TitleLabel.Text = e.Hint
e.TitleLabel.Color, e.LineColor = e.t.Color.Primary, e.t.Color.Primary
Expand Down Expand Up @@ -312,6 +315,7 @@ func (e *Editor) editorLayout(gtx C) D {
}

func (e *Editor) editorMenusLayout(gtx C, editorHeight int) {
e.isShowMenu = e.isShowMenu && (e.Editor.Focused() || e.copy.Hovered() || e.paste.Hovered())
if e.isShowMenu {
flexChilds := make([]layout.FlexChild, 0)
if len(e.Editor.Text()) > 0 {
Expand Down Expand Up @@ -433,9 +437,7 @@ func (e *Editor) handleEvents(gtx C) {
}

if e.paste.Clicked() {
if e.eventKey > 0 {
clipboard.ReadOp{Tag: &e.eventKey}.Add(gtx.Ops)
}
clipboard.ReadOp{Tag: &e.eventKey}.Add(gtx.Ops)
e.isShowMenu = false
}
}
Expand Down

0 comments on commit f7b5f22

Please sign in to comment.