PROGRESS 4GL Freeze after APPLY "Enter" - handle

I update some fields with external procedure ( i cannot modify base program ) .
I try to jump over field I need, but on one, my program is freezing.
The procedure looks like that:
PAUSE 0 NO-MESSAGE.
IF FOCUS = field1
THEN DO:
field1:screen-value = ''.
APPLY 'ENTER' .
PAUSE 0 .
END.
IF FOCUS = field2
THEN DO:
field2:screen-value = 'U'.
APPLY 'ENTER' .
PAUSE 0 .
END.
IF FOCUS = field3
THEN DO:
field3:screen-value = 'N'.
APPLY 'ENTER' .
PAUSE 0 .
APPLY 'ENTER' .
PAUSE 0.
END.
PAUSE 0.
I put PAUSE 0, because its solve similiar case when I was in field2, but in field3 its not working.
What others step I can make?
Thank You for answers.
Regards.
e: When i said "Freeze" i mean Its waiting for any key. After 'any key' it goes onwards.
Its problem, because i neet to automatize evrything .
e: And now i guess its not after APPLY statement but in some moment when i jumping over the fields. When i normally use the original program this freeze/waiting for key is unseen. So what in the code above can cause such an effect?
e: Its after APPLY "ENTER" on specific fields. Not for evry but some fields causes freezing ( not with Press Space message ). Pause 0 not working for them.
e: After using only this code :
IF FOCUS = field1
THEN DO:
APPLY 'ENTER' .
APPLY 'COMPLETE' TO FOCUS.
PAUSE 0.
MESSAGE 'dfdfd' VIEW-AS ALERT-BOX.
END.
Its freezing after showing the message. Dont know why...

You've applied "enter". So your code must RETURN NO-APPLY or it is going to undo the application of ENTER.

Related

Checking if key is being held down

I've got a game where you place towers on the map, it's working fine they can click and the towers place the the build mode is set to false. I Want to allow the player to hold shift down then they can place multiply towers then when they release shift the build mode will change to false but i can't figure it out.
This is what i've got so far but doesn't seem to work as intended
func _input(event):
if event.is_action_released("ui_accept") and build_mode == true:
verify_and_build()
if event.is_action_released("multi_build"):
cancel_build_mode()
I've assigned ui_accept to left click and multi_build to Shift
You are going to get a call to _input per input event. And the event object you get as parameter in _input represents that single input.
If want to to this with the event object, it would be something like this:
func _input(event):
if event.is_action_pressed("multi_build"):
build_mode = true
if event.is_action_released("multi_build"):
build_mode = false
Alternatively, you can use Input to check if the action is currently pressed: Input.is_action_pressed("multi_build").

AHK in MS Excel (Cell Selection Issue With Script)

I started a little script using CAPSLock key for navigation (This is only part of the code):
SetCapsLockState, AlwaysOff
CapsLock & i::
if getkeystate("alt") = 0
Send,{Up}
else
Send,+{Up}
return
CapsLock & l::
if getkeystate("alt") = 0
Send,{Right}
else
send, +{Right}
return
It works perfectly everywhere.. except in MS Excel!
When I select a range of cells the selection marquee is there but no cell reference is taken in the formula.
Ex: Summing C3:C10 turns into =sum() no cells are actually selected in the formula.
if I keep trying up and down many times.. it shows, but never consistent.
Any idea how to fix this?
Thank you in advance
The problem comes from your shift key being released between the key presses.
Like for example try pressing keys like this in Excel and you'll see you're not actually selecting cells, you're just highlighting them:
Shift Down, Up Arrow, Shift Up
Shift Down, Up Arrow, Shift Up
Shift Down, Up Arrow, Shift Up
...
So you're going to have to keep shift pressed for the whole duration of your selection making process.
Here's what I could come up with:
CapsLock::Shift
#If, GetKeyState("CapsLock", "P")
*i::
if (GetKeyState("Alt", "P"))
SendInput, {Blind}{Alt Up}{Up}
else
SendInput, {Up}
return
*l::
if (GetKeyState("Alt", "P"))
SendInput, {Blind}{Alt Up}{Right}
else
SendInput, {Down}
return
#If
Or just like this to write it a lot cleaner with a ternary:
CapsLock::Shift
#If, GetKeyState("CapsLock", "P")
*i::SendInput, % GetKeyState("Alt", "P") ? "{Blind}{Alt Up}{Up}" : "{Up}"
*l::SendInput, % GetKeyState("Alt", "P") ? "{Blind}{Alt Up}{Right}" : "{Right}"
#If
So what's happening?
First we use the simple remapping syntax(docs) to remap CapsLock to Shift.
Then we create context sensitive hotkeys for I and L with #If(docs).
The hotkeys are only triggered if the physical state of CapsLock is down.
We need the physical state, because the logical state (which is default) was remapped to shift.
The hotkeys are created with the * modifier(docs) so they fire even if Shift and/or Alt is held down.
I switched the Send commands SendInput due to it being the recommended faster and more reliable send mode(docs).
And then about {Blind}. Normally, when you just send something with a send command, it automatically releases any modifiers you may be holding. But if you use the blind send mode(docs), this doesn't happen. So Shift is still held down all the time.

insert GlyphProperty.null in shouldGenerateGlyphs causes cursor misplacement problem

I am hiding the character * by inserting GlyphProperty.null then calling setGlyphs(_:properties:characterIndexes:font:forGlyphRange:) inside layoutManager(_:shouldGenerateGlyphs:properties:characterIndexes:font:forGlyphRange:) as described in the answer in https://stackoverflow.com/a/57697139/9568961, it works but after a certain sequence of text editing, the cursor starts to misplace, as shown in the gif https://github.com/dzAtZJU/Demos/blob/master/cursor_misplace.GIF?raw=true
GIF Description: When the second line becomes qq, I try to move the cursor to the end of first line, but it move directly to the beginning. I then try to delete characters, then the cursor move to the end correctly.
The sample project is here https://github.com/dzAtZJU/HideText.
Is it a bug? Have anyone run into this? How can I work around this?
This is a year-old question, but for anyone struggling with the same problem, here's a solution.
My Markdown-like parser knows the ranges for both the line on which the cursor is now, and where it was previously. I'm calling hideAndShowMarkup whenever text view selection changes.
You need to invalidate current glyphs for both of the ranges, and then redraw them synchronously before updating insertion point. The most crucial step is invalidating layout for the range where you want to show Markdown symbols. Without that, your caret gets drawn into the wrong position.
Code is in Objective C, but should be easy to implement in Swift, too.
-(void)hideAndShowMarkup {
// Just for reference
Line* line = currentLine;
Line* prevLine = previouslySelectedLine;
[self.layoutManager invalidateGlyphsForCharacterRange:line.range changeInLength:0 actualCharacterRange:nil];
[self.layoutManager invalidateGlyphsForCharacterRange:prevLine.range changeInLength:0 actualCharacterRange:nil];
[self.layoutManager invalidateLayoutForCharacterRange:line.range actualCharacterRange:nil];
if (NSGraphicsContext.currentContext) {
[self.layoutManager drawGlyphsForGlyphRange:line.range atPoint:self.frame.origin];
[self.layoutManager drawGlyphsForGlyphRange:prevLine.range atPoint:self.frame.origin];
}
[self updateInsertionPointStateAndRestartTimer:NO];
}

How to add brackets using AutoHotKey

I want to create a hotkey Ctrl + ( that adds brackets to a phrase. I.e select x-1 to get (x-1). How to program this function?
I write a lot of phrases such as: x+1/(x-1)^2 so it would be helpful to have a hotkey to add brackets.
^(::
SendInput, ^c
Sleep 10
Clipboard = (%Clipboard%)
SendInput, ^v
return
This implies that you are actually pressing CTRL+SHIFT+9 (since you don't have a ( key).
I did a quick test and it will add round brackets to anything you highlight. I would recommend tweaking the trigger key since CTRL+SHIFT+9 isn't that easy to hit, but otherwise seems to work without issues.
If you want to save the clipboard, then you'll have to do this:
^(::
SavedClipboard := ClipboardAll
SendInput, ^c
Sleep 10
Clipboard = (%Clipboard%)
SendInput, ^v
Clipboard := SavedClipboard
SavedClipboard =
return

How to exit program with close button in XCB

Can not find any reference on how to close application by the "X" button. I'm programming using XCB and want to close the program by the "X" button. I looked and can't find anything about it. I know how to close by pressing a button. Also, by pressing the "X" button the window looks like it closes but doesn't.
I struggled on this topic some time ago as well.
Look at http://marc.info/?l=freedesktop-xcb&m=129381953404497 .
The key is to store the cookie for the WM_DELETE_WINDOW in a separate cookie...
xcb_intern_atom_cookie_t cookie2 = xcb_intern_atom(c, 0, 16, "WM_DELETE_WINDOW");
xcb_intern_atom_reply_t* reply2 = xcb_intern_atom_reply(c, cookie2, 0);
and in the event loop compare the client_message with the cookie2
case XCB_CLIENT_MESSAGE:
{
if((*(xcb_client_message_event_t*)event).data.data32[0] == (*reply2).atom) ...
}

Resources