better buttons

dev-srcloc
Matthew Butterick 8 years ago
parent 23b3b2e56c
commit 5ce9a0df37

@ -1,18 +1,15 @@
#lang br #lang br
(require racket/draw) (require br/drracket)
(provide make-button)
(define label "Insert expression") (define (button-func drr-window)
(define bitmap (make-object bitmap% 16 16)) (define expr-string "@$ $@")
(define (callback drr-frame) (define editor (send drr-window get-definitions-text))
(define drr-editor (send drr-frame get-definitions-text)) (send editor begin-edit-sequence)
(define block-string "@$ $@") (send editor insert expr-string)
(send drr-editor begin-edit-sequence) (send editor end-edit-sequence)
(send drr-editor insert block-string) (define pos (send editor get-end-position))
(send drr-editor end-edit-sequence) (send editor set-position (- pos (/ (string-length expr-string) 2))))
(define pos (send drr-editor get-end-position))
(send drr-editor set-position (- pos (/ (string-length block-string) 2))))
(define number 98)
(define make-button (define button-list
(list (list label bitmap callback number))) (list (make-drracket-button "Insert expression" button-func)))
(provide button-list)

@ -10,7 +10,7 @@
[(drracket:indentation) [(drracket:indentation)
(dynamic-require 'br/demo/jsonic-2/indenter 'indent-jsonic)] (dynamic-require 'br/demo/jsonic-2/indenter 'indent-jsonic)]
[(drracket:toolbar-buttons) [(drracket:toolbar-buttons)
(dynamic-require 'br/demo/jsonic-2/buttons 'make-button)] (dynamic-require 'br/demo/jsonic-2/buttons 'button-list)]
[else default])) [else default]))
handle-query)) handle-query))

Loading…
Cancel
Save