76
Programming Challenges / Re: GUI Login
« on: December 25, 2019, 11:12:38 PM »
8th (Jalih submission)
Code: Text
- requires gui
- var gui
- { guest: "pa$$w0rd!" } constant passwords
- : authenticate
- "edit1" g:child g:text? passwords swap m:@ nip null? if
- "User not found!" . cr
- 2drop
- else
- swap
- "edit2" g:child g:text? nip s:= if
- "Authenticated!" . cr
- bye
- else
- "Username and password don't match!" . cr
- then
- then ;
- {
- kind: "win",
- buttons: 5,
- title: "Login",
- wide: 360,
- high: 160,
- resizable: false,
- bg:"lightgray",
- center: true,
- init: ( gui ! ),
- children:
- [
- {
- kind: "box",
- name: "frame",
- bounds: "10, 10, parent.width-10, parent.height-10",
- bg: "gray",
- children:
- [
- {
- kind: "label",
- label: "Username:",
- bounds: "parent.left, parent.top+10, 80, top+24 ",
- name: "lbl1"
- },
- {
- kind: "edit",
- bounds: "lbl1.right+10, lbl1.top, parent.width-10, top+24",
- name: "edit1",
- max-text: 32
- },
- {
- kind: "label",
- label: "Password:",
- bounds: "lbl1.left, lbl1.bottom+10, 80, top+24 ",
- name: "lbl2"
- },
- {
- kind: "edit",
- bounds: "edit1.left, lbl2.top, parent.width-10, top+24",
- name: "edit2",
- max-text: 32,
- password-char: "*"
- },
- {
- kind: "btn",
- label: "Login",
- bg: "darkgray",
- bounds: "lbl2.left, lbl2.bottom+20, edit2.right, top+30",
- name: "button",
- tooltip: "Login to account",
- click: ' authenticate
- }
- ]
- }
- ]
- } var, gui-desc
- : app:main
- gui-desc @ g:new ;