Keyboard input/Obtain a Y or N response: Difference between revisions

m
no edit summary
(Added C++)
mNo edit summary
Line 798:
}
}, false);</lang>
 
=={{header|Julia}}==
Uses the Gtk library.
<lang julia>
using Gtk.ShortNames
 
 
function clickwindow()
clicks = 0
win = Window("Click Counter", 300, 100) |> (Frame() |> (vbox = Box(:v)))
lab = Label("There have been no clicks yet.")
but = Button("click me, or type Y or N")
push!(vbox, lab)
push!(vbox, but)
setproperty!(vbox, :expand, lab, true)
setproperty!(vbox, :spacing, 20)
callback(w) = (clicks += 1; setproperty!(lab, :label, "There have been $clicks button clicks."))
signal_connect(callback, but, "clicked")
keycall(w, event) = (ch = Char(event.keyval)) in('n','N','y','Y') ? setproperty!(lab,:label,"You hit the $ch key."): 0
signal_connect(keycall, vbox, "key-press-event")
c = Condition()
endit(w) = notify(c)
signal_connect(endit, win, :destroy)
showall(win)
wait(c)
end
 
 
clickwindow()
</lang>
 
 
=={{header|Kotlin}}==
4,105

edits