{"id":18447061,"url":"https://github.com/zot/go-fltk","last_synced_at":"2025-04-08T00:31:59.434Z","repository":{"id":1157103,"uuid":"1044248","full_name":"zot/go-fltk","owner":"zot","description":"Basic Go bindings for FLTK","archived":false,"fork":false,"pushed_at":"2010-12-20T01:46:12.000Z","size":121,"stargazers_count":32,"open_issues_count":3,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-23T03:32:12.429Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zot.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2010-11-02T09:49:24.000Z","updated_at":"2024-09-10T23:32:51.000Z","dependencies_parsed_at":"2022-08-16T12:25:06.845Z","dependency_job_id":null,"html_url":"https://github.com/zot/go-fltk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zot%2Fgo-fltk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zot%2Fgo-fltk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zot%2Fgo-fltk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zot%2Fgo-fltk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zot","download_url":"https://codeload.github.com/zot/go-fltk/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247755426,"owners_count":20990617,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-06T07:11:51.623Z","updated_at":"2025-04-08T00:31:59.089Z","avatar_url":"https://github.com/zot.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[Go FLTK](http://github.com/zot/go-fltk)\n========================================\n\nThis is a simple go wrapper for [FLTK2](http://www.fltk.org/doc-2.0/html/index.html), which I did to support my Go version of Ober (based on Acme), [Gober](http://github.com/zot/Gober).  It's very small and should be fairly easy to extend to support whatever other widgets and functionality you need.  Please contribute changes you make.  The code is licensed under the very permissive ZLIB license.  FLTK2 is only somewhat supported, but I like its mouse-text behavior better than FLTK 1.3's.\n\n\nGOALS\n=====\n* *Good integration with Go* -- the way this binding processes events lends itself well to Go programs (I think).  since there is not call-in from C to Go, only call-out from Go to C, this runs FLTK in a separate thread in order to allow Go to intercept every event.  Go FLTK operations are protected so that they are safe to use in goroutines.\n* *Simplicity* -- I'm trying to keep the code small, mostly in Go, generic (multipurpose, but not fat), easy to modify, and easy to extend\n* *Small and relatively stand-alone* -- I wanted a toolkit that only depended on basic X functionality and was relatively small so I could statially link it into the Go package.  At this point, fltk.a is 121K and cgo_fltk.so is 312K.  Yes, I'm sitting here with a straight face and claiming that this is \"small.\"  Widget kits are usually several megabytes, so this is small.  Maybe someday this will even be a service instead of a library.\n\n\nLIMITED FUNCTIONALITY\n=====================\nThis wrapper is far from complete, and I'm only planning on supporting what I need to do Gober, but I welcome additions to it.  In fact, at this point it hardly does anything.  I'll flesh things out as I need them for Gober.\n\n\nUSING Go FLTK\n=============\n* fltk.Run(while func() bool) runs FLTK until while() returns false.  Run() is defined like this:\n\tfor (while()) {ContinueEvent(Handle(ReadEvent()))}\n* fltk.ReadEvent() returns the next *Event structure read\n* fltk.Handle(event *Event) runs the widget's event handler (if there is one) and returns what the handler returned (1 means the widget used the event, 0 means it did not)\n* fltk.ContinueEvent(status int) allows FLTK to continue processing.  If you do not call this, the GUI will hang.\n\nBy default, widgets have empty handlers, so you can treat fltk as an event stream if you like, instead of using event handlers (wait for an event, process the event yourself), which may lend itself well to using Go channels, since Go FLTK operations are safe to use in goroutines.  That boils down to four ways you can deal with events:\n\n\tcase 1, process an event after the widget handles it:\n\n\t\tuser event --\u003e widget --\u003e go event handler\n\n\tcase 2, process an event before the widget handles it (event stealing):\n\n\t\tuser event --\u003e go event handler [optionally: --\u003e widget]\n\n\tcase 3, roll your own, with default widget behavior (without an event handler):\n\n\t\tuser event --\u003e widget --\u003e roll your own with the current event\n\n\tcase 4, roll your own, with no default widget behavior (stealing without an event handler):\n\n\t\tuser event --\u003e roll your own with the current event [optionally: --\u003e widget]\n\nYou can install an event handler with widget.SetEventHandler() like this:\n\n    input.SetEventHandler(func(e fltk.Event){println(e.Event)}\n\nNormally, the widget processes the event before Wait returns but you can \"steal\" events so that your event handler will get the event before the widget has a chance to process it.  If you want to steal events, call widget.StealEvents() with a bit mask for the FLTK event types.  There are constants for the event types and masks for them by appending _MASK to the name, like PUSH_MASK, which is just 1 \u003c\u003c PUSH.  You call StealEvents() like this:\n\n   input.StealEvents((1 \u003c\u003c PUSH_MASK) | (1 \u003c\u003c DRAG_MASK))\n\nThere is a bool field in Event, called \"Stolen\" to tell you whether the event was stolen.  If you want the widget to process the stolen event, just call widget.ContinueEvent().  Here is an example of an event handler that prints a message for stolen push and drag events and then continues them:\n\n\ti.StealEvents(fltk.PUSH_MASK | fltk.DRAG_MASK)\n\ti.SetEventHandler(func(e fltk.Event) {\n\t\tif (e.Stolen) {\n\t\t\tprintln(\"CONTINUING EVENT: \" + strconv.Itoa(e.Event))\n\t\t\ti.ContinueEvent()\n\t\t}\n\t})\n\nThere is an example program, test.go, in the \"examples\" directory, that steals events from a text field, like this.\n\n\nDEPENDENCIES\n============\nThe make file SHOULD auto-download and unpack FLTK2 for you.  When it builds the Go library, it statically links FLTK into the library so that the only dependencies are -lXext -lXinerama -lXft -lX11 -lXi -lm.\n\nThis only runs under X, because of the way I build it, but FLTK purports to run on windows and macs, so if you can test that and help with the Makefile, I'd appreciate it.\n\n\nBUILDING\n========\nTo build, run \"make\" in the top-level directory.  This assumes you have g++ installed, because FLTK is written in C++ and you need to use g++ to link the library so it can resolve mangled names.\n\nTo install the library, run \"make install\".\n\nTo build the examples, run \"make examples\".\n\nIf you want to eliminate the fltk-library from your directory, you can run \"make clean-fltk\".\n\n\nEXAMPLES\n========\nThere are two examples: hello and text.  Hello is the Hello World program from the [FLTK docs](http://www.fltk.org/doc-2.0/html/example1.html) and text is a window with a text field in it that steals the PUSH and DRAG events, printing a message and continuing the events.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzot%2Fgo-fltk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzot%2Fgo-fltk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzot%2Fgo-fltk/lists"}