Hello, I have a text input widget which takes a single line of text and has a scrollbar widget beneath it that lets the user move the cursor in the visible text.


This only works once the user has clicked somewhere in the text so that the cursor is visible and I am quite happy with that. If the user moves the cursor with the left or right keyboard arrows and inserts extra text or deletes text at some point in the string, as soon as the string changes, there is a callback that moves the scroll bar to the part of the string that is being edited. That is good because it shows where the changes are being made relative to the length of the string.
What I would like it to do is to move the scrollbar whenever the user navigates with the left or right keyboard arrow. Note I mean the keyboard arrows, not the left or right scroller arrows which work correctly. At the moment the callback which moves the slider is set to be called by:
inpseq->when(FL_WHEN_CHANGED);
and I have tried the various options like WHEN_NOT_CHANGED, WHEN_RELEASED, WHEN_NOT_RELEASED and WHEN_NOT_RELEASED_ALWAYS but these don’t work for my purposes.
I also tried changing Greg’s function which pastes in the text with a right mouse click (!) to add something which detects left and right arrow keyboard events.


With that, if I click somewhere in the text to edit it, I am not longer able to make any changes or move the cursor left or right, but it does move the slider! Evidently the red text above says the code is ‘masking’ the keyboard keys from their normal role!! Is there anyway that I can unmask them from this!?
Sorry, I am still on 1.3.8 and meanwhile I will try to update as far as my linux distro and 20 YO computer allow, in case that helps. Cheers, Jon.C.
Without seeing more of your code in context, it's hard to be sure, since there are a number of things that could be awry here.However, there are a few things that strike me straight away.
Firstly, what do you think the line:
if ( Fl::event_button() == FL_Left | FL_Right) {
Is testing for?I'm assuming you envisage that as saying "If ( Fl::event_button() == FL_Left) || ( Fl::event_button() == FL_Right )" but that's not what you have coded.That test will OR FL_Left with FL_Right, i.e. ( 0xff51 | 0xff53 ) then test the result (which results in just 0xff53 again, or FL_Right) so in effect that's ONLY looking for FL_Right.I doubt that's what you intended.
if (Fl::event_button() == FL_Left) || (Fl::event_button() == FL_Right) {
Note also that Fl::event_button() is
only defined when used inside mouse button press event handling and
returns distinct (enum) values for the respective mouse buttons
(FL_LEFT_MOUSE, FL_MIDDLE_MOUSE, FL_RIGHT_MOUSE, FL_BACK_MOUSE,
FL_FORWARD_MOUSE), see documentation here:FL_Left and FL_Right are keyboard key values which would be the correct keys to test, but then Fl::event_key() would be the proper method to use inside `case FL_KEYBOARD:`, something like:
if (Fl::event_button() == FL_Left) || (Fl::event_button() == FL_Right) {
if ((Fl::event_key() == FL_Left) || (Fl::event_key() == FL_Right)) {
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkgeneral/5d01cee4-5564-4b82-9b65-98556200a664%40aljus.de.

Sorry, I forgot to mention about upgrading from 1.3.8 to 1.4.5. I can't remember exactly the order of things but the files from github didn't work initially with "sudo ./configure" so I eventually had to run it with "sudo ./configure --disable-xft" but I actually can't remember what I was doing very well and I had bad fonts initially but this is the command history which I can find, although I am not sure if it is everything:
--
You received this message because you are subscribed to the Google Groups "fltk.general" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkgeneral...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/fltkgeneral/6a457264-507e-4c99-ae55-32408160d30an%40googlegroups.com.