Comments (10)
isn't it possible to use this type of keyboard handling ?
The signal is available in GTK3 (https://docs.gtk.org/gtk3/signal.Widget.key-press-event.html), while it got removed in GTK4 (https://docs.gtk.org/gtk4/class.Window.html).
also don't know if it is related but when i am using slime i get
Try evaluating this:
from cl-gtk4.
Thank you for discovering and pointing out my oversight in the API conversion. This is an issue with the wrapper, which I will fix in the near future.
from cl-gtk4.
thanks for your quick reply !
concerning the second problem, i found a way to do it
main trick is to directly call the gir-property function like so (setf (gir:property tag 'foreground) fg-color)
example :
(defun get-iter-at-line (buffer line)
(multiple-value-bind (ok? iter) (text-buffer-get-iter-at-line buffer line)
(when ok? iter)
))
(defun tag-create (table name &optional (fg-color "green") (bg-color "yellow"))
(let ((tag (text-tag-table-lookup table name)))
(if tag
(text-tag-table-remove table tag)
(setf tag (make-text-tag :name name))
)
(setf (gir:property tag 'foreground) fg-color)
(setf (gir:property tag 'background) bg-color)
(text-tag-table-add table tag)
(text-buffer-apply-tag b tag (get-iter-at-line b 0) (get-iter-at-line b 1))
)
)
from cl-gtk4.
concerning the second problem, i found a way to do it main trick is to directly call the gir-property function like so (setf (gir:property tag 'foreground) fg-color)
This is currently one alternative approach, but further exploration is needed on whether and how to convert GObject properties to constructor parameters and accessors in Lisp while preserving the existing interface.
from cl-gtk4.
thx, still i have difficulties to deal with keyboard inputs
i did not find a way to use usual connection signals (see my first post above) so i am using
(key-controller (make-event-controller-key))
(connect key-controller "key-pressed" (lambda (event &rest args) ))
but it is somehow inconvenient and instable, as it throws at times messages like
gtk_event_controller_get_propagation_phase: assertion 'GTK_IS_EVENT_CONTROLLER (controller)' failed
from cl-gtk4.
but it is somehow inconvenient and instable, as it throws at times messages like
Sorry, I can't reproduce the issue. Here is my code, which works stably for me:
(ql:quickload :cl-gdk4)
(in-package #:gtk4)
(defun main ()
(let ((application (make-application :application-id "org.bohonghuang.gtk4-event-test" :flags gio:+application-flags-flags-none+)))
(connect application "activate" (lambda (app)
(let ((window (make-application-window :application app))
(controller (make-event-controller-key)))
(connect controller "key-pressed" (lambda (&rest args)
(print args)
(values gdk:+event-propagate+)))
(widget-add-controller window controller)
(window-present window))))
(application-run application nil)))
from cl-gtk4.
it seems to be related to threading
sorry i did not mention it but i am willing to develop interactively so whenever i am setting a swank server i end up with this problem
isn't it possible to use this type of keyboard handling ?
g_signal_connect (G_OBJECT (window), "key_press_event", G_CALLBACK (gkeypress), NULL);
also don't know if it is related but when i am using slime i get
arithmetic error FLOATING-POINT-INVALID-OPERATION signalled
[Condition of type FLOATING-POINT-INVALID-OPERATION]
Restarts:
0: [ABORT] Abort compilation.
1: [*ABORT] Return to SLIME's top level.
2: [ABORT] abort thread (#<THREAD "worker" RUNNING {1004538BF3}>)
Backtrace:
0: ((FLET SB-UNIX::RUN-HANDLER :IN SB-UNIX::%INSTALL-HANDLER) 8 #.(SB-SYS:INT-SAP #X7F5F7A60CA70) #.(SB-SYS:INT-SAP #X7F5F7A60C940))
1: ("foreign function: call_into_lisp_")
2: ("foreign function: funcall3")
3: ("foreign function: interrupt_handle_now_handler")
4: ((LAMBDA (&REST GIR::ARGS-IN) :IN GIR::BUILD-FUNCTION) #.(SB-SYS:INT-SAP #X7F5F7408F180) NIL)
5: (GIO:APPLICATION-RUN #<GIR::OBJECT-INSTANCE {1004DA1A23}> NIL)
from cl-gtk4.
thanks, it solved my pb !
from cl-gtk4.
and as for the instability problem when using other threads (like swank)
setting event propagation phase not to bubble up seems to solve the mysterious error message :
gtk_event_controller_get_propagation_phase: assertion 'GTK_IS_EVENT_CONTROLLER (controller)' failed
(setf (gtk4:event-controller-propagation-phase key-controller) gtk4:+propagation-phase-capture+)
from cl-gtk4.
and as for the instability problem when using other threads (like swank)
Unfortunately, I have never encountered this issue in my use case. If it is an error caused by multithreading, you should make sure that the code interacting with GTK is executed within (gtk:run-in-main-event-loop () ...)
.
from cl-gtk4.
Related Issues (20)
- Can't make a GStream binding. HOT 1
- Typelib file for namespace 'Gtk', version '4.0' not found HOT 4
- How to make a GListStore of fixnums / How to subclass GObject HOT 2
- Library needs more documentation HOT 1
- Can't create simple application. HOT 4
- FLOATING-POINT-INVALID-OPERATION HOT 5
- arithmetic error DIVISION-BY-ZERO signalled HOT 2
- Cant create wigets to store it in variable HOT 1
- When vertically scaling the window, there is an artifact with the buttons. HOT 1
- No symbol named "POINTER-OBJECT" HOT 2
- Error g_error_free on Windows 11 HOT 6
- Can't properly pass "user_data" to callback for open file dialog HOT 2
- Support for Subclassing? HOT 1
- Radio buttons HOT 1
- Connect widget to key-pressed event HOT 3
- Can I create my own widgets? HOT 2
- (ql:quickload :cl-gtk4) fails, many issues: HOT 3
- Hoping for examples or documents about dialogs HOT 2
- Making executable HOT 2
- cl-gtk4 not working under SBCL v2.4.5 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cl-gtk4.