Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue#9 #46

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions gwu/textbox_pwbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ type textBoxImpl struct {
hasEnabledImpl // Has enabled implementation

isPassw bool // Tells if the text box is a password box
isFile bool // Tells if the text box accepts a file path
rows, cols int // Number of displayed rows and columns.
}

Expand All @@ -110,21 +111,28 @@ var (

// NewTextBox creates a new TextBox.
func NewTextBox(text string) TextBox {
c := newTextBoxImpl(strEncURIThisV, text, false)
c := newTextBoxImpl(strEncURIThisV, text, false, false)
c.Style().AddClass("gwu-TextBox")
return &c
}

// NewFileInputBox creates a new TextBox that accept a file path.
func NewFileInputBox(text string) TextBox {
c := newTextBoxImpl(strEncURIThisV, text, false, true)
c.Style().AddClass("gwu-TextBox")
return &c
}

// NewPasswBox creates a new PasswBox.
func NewPasswBox(text string) TextBox {
c := newTextBoxImpl(strEncURIThisV, text, true)
c := newTextBoxImpl(strEncURIThisV, text, true, false)
c.Style().AddClass("gwu-PasswBox")
return &c
}

// newTextBoxImpl creates a new textBoxImpl.
func newTextBoxImpl(valueProviderJs []byte, text string, isPassw bool) textBoxImpl {
c := textBoxImpl{newCompImpl(valueProviderJs), newHasTextImpl(text), newHasEnabledImpl(), isPassw, 1, 20}
func newTextBoxImpl(valueProviderJs []byte, text string, isPassw, isFile bool) textBoxImpl {
c := textBoxImpl{newCompImpl(valueProviderJs), newHasTextImpl(text), newHasEnabledImpl(), isPassw, isFile, 1, 20}
c.AddSyncOnETypes(ETypeChange)
return c
}
Expand Down Expand Up @@ -202,6 +210,7 @@ var (
strInputOp = []byte(`<input type="`) // `<input type="`
strPassword = []byte("password") // "password"
strText = []byte("text") // "text"
strFile = []byte("file") // "file"
strSize = []byte(`" size="`) // `" size="`
strValue = []byte(` value="`) // ` value="`
strInputCl = []byte(`"/>`) // `"/>`
Expand All @@ -212,6 +221,8 @@ func (c *textBoxImpl) renderInput(w Writer) {
w.Write(strInputOp)
if c.isPassw {
w.Write(strPassword)
} else if c.isFile{
w.Write(strFile)
} else {
w.Write(strText)
}
Expand Down