[Lazarus] How to detect that the Alt-key is released?

2015-08-02 Thread Jürgen Hestermann

According to http://wiki.lazarus.freepascal.org/LCL_Key_Handling
the KeyUp event should be triggered when the Alt-key is released.

But how do I tell this procedure that I want to check for the Alt-key?
The key parameter is of type word.
What is the representation of the Alt-key here?
vk_alt does not exist.

And how about the Shift parameter?
It would tell me whether Alt is currently pressed or not
but not whether it has been released.

A bit confusing
Anybody knows how it works?


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to detect that the Alt-key is released?

2015-08-02 Thread Jürgen Hestermann

Am 2015-08-02 um 14:33 schrieb JuuS:

(btw. this WON'T work in onkeyup with just the alt key...when you lift
alt (ie, keyup) it is no longer down and so is not in Shift, to see it
work do something like alt-a).


But that's just what I want:
Detect the release of the Alt+key (independend from other keys state).

So it's not possible?

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to detect that the Alt-key is released?

2015-08-02 Thread JuuS
Sorry I confused you, my specialty.

What I meant was if you use the 'ssAlt in Shift' line, it won't work if
you only press the alt key because in a keyup handler the key is then
up! And so won't pass the if statement. It would work in a keydown
handler though.

if you press and hold alt and then press and release, for example, 'a'
you will see it catch the state of the alt key.

as to the vk_menu, no idea. But to detect states of shift, control, alt,
etc. the methods I showed are what is normally used.



On 08/02/2015 02:42 PM, Jürgen Hestermann wrote:
 Am 2015-08-02 um 14:33 schrieb JuuS:
 (btw. this WON'T work in onkeyup with just the alt key...when you lift
 alt (ie, keyup) it is no longer down and so is not in Shift, to see it
 work do something like alt-a).
 
 But that's just what I want:
 Detect the release of the Alt+key (independend from other keys state).
 
 So it's not possible?
 
 -- 
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] How to detect that the Alt-key is released?

2015-08-02 Thread JuuS
Hi,

Shift keys are handled differently. When you to to the declaration of
TShiftState you'll see:

  TShiftStateEnum = (ssShift, ssAlt, ssCtrl,
ssLeft, ssRight, ssMiddle, ssDouble,
// Extra additions
ssMeta, ssSuper, ssHyper, ssAltGr, ssCaps, ssNum,
ssScroll,ssTriple,ssQuad,ssExtra1,ssExtra2);

  TShiftState = set of TShiftStateEnum;


And you use it like:

if ssAlt in Shift then
  showmessage( 'Ye. Alt.' ).

(btw. this WON'T work in onkeyup with just the alt key...when you lift
alt (ie, keyup) it is no longer down and so is not in Shift, to see it
work do something like alt-a).

or

if [ ssShift, ssCtrl ] * Shift = [] then
showmessage( 'shift or ctrl' );

play around with them, you'll get the results you want.


Also, you probably already know, be sure the form's keypreview property
is set to true.

Julius


On 08/02/2015 12:52 PM, Jürgen Hestermann wrote:
 According to http://wiki.lazarus.freepascal.org/LCL_Key_Handling
 the KeyUp event should be triggered when the Alt-key is released.
 
 But how do I tell this procedure that I want to check for the Alt-key?
 The key parameter is of type word.
 What is the representation of the Alt-key here?
 vk_alt does not exist.
 
 And how about the Shift parameter?
 It would tell me whether Alt is currently pressed or not
 but not whether it has been released.
 
 A bit confusing
 Anybody knows how it works?
 
 
 -- 
 ___
 Lazarus mailing list
 Lazarus@lists.lazarus.freepascal.org
 http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] Fwd: Re: How to detect that the Alt-key is released?

2015-08-02 Thread Jürgen Hestermann

Am 2015-08-02 um 14:42 schrieb Jürgen Hestermann:
 Am 2015-08-02 um 14:33 schrieb JuuS:
 (btw. this WON'T work in onkeyup with just the alt key...when you lift
 alt (ie, keyup) it is no longer down and so is not in Shift, to see it
 work do something like alt-a).
 But that's just what I want:
 Detect the release of the Alt+key (independend from other keys state).
 So it's not possible?

Well, I just found out how it works myself:

---
procedure TForm1.FormKeyUp(Sender: TObject; var Key: Word; Shift: TShiftState);
begin
if Key=vk_Menu then
   ShowMessage(' ALT key released');
end;
---

The main point I missed was that I did not know that the Alt-key is vk_Menu.
A strange name for the Alt-key. ;-(

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


[Lazarus] TEdit: Find character at caret position

2015-08-02 Thread Jürgen Hestermann

In a TEdit component, how do I find out which character is at the caret/cursor 
position?
Or in other words: At which (string) position will the next typed character be 
inserted?
I want to insert text at just that position myself but cannot find out where 
this (character) position would be.

Any help appreciated.

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] TEdit: Find character at caret position

2015-08-02 Thread Howard Page-Clark

On 02/08/2015 18:33, Jürgen Hestermann wrote:

In a TEdit component, how do I find out which character is at the
caret/cursor position?
Or in other words: At which (string) position will the next typed
character be inserted?
I want to insert text at just that position myself but cannot find out
where this (character) position would be.


Edit1.SelStart gives the character position of the caret/cursor. The 
next typed character is inserted at Succ(Edit1.SelStart).


Howard


---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Printing BitMap on OSX crashes

2015-08-02 Thread Martin Frb

On 02/08/2015 20:20, Martin Grajcar wrote:


Maybe you can help me with this: How can I get the debugger 
(lazarus/gdb) show the C code? All I get for the innermost frames is 
an address and assembler. No idea what to install (and Google really 
didn't help).



I dont know if that is possible at all.  If it is, its gonna be tricky.

First of all:
The c code must be compiled with the same debug info (stabs or dwarf) as 
the pascal code.


I haven't followed the thread, so I do not know if the c code is in a 
library (dynamically loaded) or linked into the exe.
If linked then the debug info must have been included by the linker. If 
in an library it must be in such a way gdb can load it(gdb should be 
able to load debug info for libraries, but I do not know the state of 
this for each platform).
If in a library then DisableLoadSymbolsForLibraries MUST NOT (is not 
allowed to) be set.
( 
http://wiki.lazarus.freepascal.org/GDB_Debugger_Tips#internal-error:_clear_dangling_display_expressions 
)


If all the above is given, then the IDE must know where the files are 
(probably need to add the to the project). Debug info does not include 
the source, it just has filename and line number.


---
you can watch gdb communications in the debug output window (view  
debug windows). So you can see what gdb responds.


Also. if you open the disassembler and single step into the c code, I 
would *expect* (never tested) that the stack window shows filenames. If 
it does not, then the debug info is either not there, or not read by gdb.



On top of that you can try to control gdb yourself. You can do this from 
the IDE.
** BUT ** This is not an official feature and never will be. This solely 
exists for developing/testing the debugger integration in the IDE (for 
Lazarus developers).

It exists as it is, no feature requests, no bug reports...

Also, it has no safeguards. It is easy to hang the entire IDE by using 
it (only when sending commands to gdb). So ensure everything is saved.


Compile the ide with   DBG_WITH_DEBUGGER_DEBUG  defined.

Restart the IDE, Open debug output window (view  debug windows). There 
is an edit field and a button (must press button, return does not work). 
You can send gdb commands.


Do not send any commands that perform run/step. This will loose the 
debug session.


--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] Printing BitMap on OSX crashes

2015-08-02 Thread Martin Grajcar
Hi Jesus,

On Sat, Aug 1, 2015 at 7:08 AM, Jesus Reyes A. jesus...@gmail.com wrote:


 The problem occurs because the bitmap is being freed before
 Printer.EndDoc. It is at this point that the bitmap data is used, but
 because it was already freed an AV occurs. I have actually fixed the
 problem, but in my current implementation resources are only be freed at
 program end. Which is not good if somebody are printing a lot. So I have
 not committed the fix, I have another plan and will try again soon.

 In the mean time, the workaround it's easy (this is not the fix I
 mentioned before which would patch the LCL+Printer support). Just create
 the bitmap before Print.BeginDoc and free it after Print.EndDoc. That
 should work.


it does, thanks a lot!

Maybe you can help me with this: How can I get the debugger (lazarus/gdb)
show the C code? All I get for the innermost frames is an address and
assembler. No idea what to install (and Google really didn't help).

Regards,
Martin.
--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus