Skip to content

feat: add TextField and Button APIs #13110

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

Merged
merged 5 commits into from
Jun 18, 2018
Merged

feat: add TextField and Button APIs #13110

merged 5 commits into from
Jun 18, 2018

Conversation

zcbenz
Copy link
Contributor

@zcbenz zcbenz commented May 30, 2018

None of the APIs are expected to be stable, and they are hidden under enable_view_api build flag.

An example creating a minimal browser:

const {app, webContents, LabelButton, BoxLayout, TopLevelWindow, TextField, View, WebContentsView} = require('electron')

let win = null
app.once('ready', () => {
  const contentView = new View()
  const contentLayout = new BoxLayout('vertical')
  contentView.setLayoutManager(contentLayout)

  const toolbar = new View()
  const toolbarLayout = new BoxLayout('horizontal')
  toolbar.setLayoutManager(toolbarLayout)
  contentView.addChildView(toolbar)

  const addressBar = new TextField()
  toolbar.addChildView(addressBar)
  toolbarLayout.setFlexForView(addressBar, 1)

  const go = new LabelButton('GO')
  toolbar.addChildView(go)

  const web = webContents.create({})
  const webview = new WebContentsView(web)
  contentView.addChildView(webview)
  contentLayout.setFlexForView(webview, 1)

  win = new TopLevelWindow()
  win.setContentView(contentView)

  go.on('click', () => web.loadURL(addressBar.getText()))
  web.on('navigation-entry-commited', (event, url) => addressBar.setText(url))
  web.loadURL('http://github.com')
})

@zcbenz zcbenz requested a review from a team May 30, 2018 07:54
@MarshallOfSound
Copy link
Member

Should these components live in a separate place to api. Like maybe it should be used through require('electron').UI.Button and require('electron').UI.TextField Etc.

Just so there is a logical and physical separation between API and UI stuff 👍

This is looking super cool

@ckerr
Copy link
Member

ckerr commented May 30, 2018

👍 on both of @MarshallOfSound's points: might be good to have a separate namespace, and this looks super cool

@zcbenz
Copy link
Contributor Author

zcbenz commented May 31, 2018

Should these components live in a separate place to api. Like maybe it should be used through require('electron').UI.Button and require('electron').UI.TextField Etc.

👍 , will do it in another pull request.

@codebytere codebytere changed the title Add TextField and Button APIs src: add TextField and Button APIs Jun 13, 2018
@codebytere codebytere changed the title src: add TextField and Button APIs feat: add TextField and Button APIs Jun 13, 2018
@eveningkid
Copy link

@zcbenz is there any way to try this out?
It looks really promising. Makes me think of your side-project! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants