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

Other events besides click events #17

Closed
djsegal opened this issue Jun 17, 2017 · 5 comments
Closed

Other events besides click events #17

djsegal opened this issue Jun 17, 2017 · 5 comments

Comments

@djsegal
Copy link
Contributor

djsegal commented Jun 17, 2017

Throughout your docs you only talk about click events:

  dom"button"(
    "generate random",
    events=Dict("click"=>@js () -> $obs[] = Math.random()),
  )

However, I want to do keyboard click events on the actual jupyter cell.

The only way I can think about doing this in your framework is to have a onload function


Do you support load events?

@djsegal
Copy link
Contributor Author

djsegal commented Jun 17, 2017

I might put some hack together where:

  • I make hidden divs with click events
  • and then press them using javascript

@djsegal
Copy link
Contributor Author

djsegal commented Jun 17, 2017

Also, I end up in this situation where I have a lot of residual scripts inside my jupyter notebooks.

I know it's not really your fault, but its causing the observer to get hit N times instead of just one

edit: fixed with a naive thisCell.off('keydown'); before i add keydown events back

@shashi
Copy link
Member

shashi commented Jun 17, 2017

why can't you just use

    events=Dict("keyup"=>@js (event) -> $obs[] = event.key)

@djsegal
Copy link
Contributor Author

djsegal commented Jun 18, 2017

I don't think that will catch it on a div?

It feels like a lot of the keyboard pressing would have to be handled on the jupyter cell level

@shashi
Copy link
Member

shashi commented Jun 18, 2017

Ah, if that's the problem, you need tabindex=1 on the div

w = Widget()
ob = Observable(w, "keys", 0)
on(println, ob)
w(
    dom"div[tabindex=1]"(style=Dict("height"=>"100px", "width"=>"100px"),
                                     events=Dict("keyup" => @js e -> $ob[] = e.keyCode))
)

@shashi shashi closed this as completed Jun 18, 2017
pfitzseb pushed a commit that referenced this issue May 12, 2021
don't checkout webio master on travis
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

No branches or pull requests

2 participants