GuvaCode / ray4laz

A complete header translation (binding) of the raylib 5.0 to Pascal. Without any funky helper functions for memory alignment issues. Inspired and partially based on the drezgames/raylib-pascal binding, however a little cleaner and more recent, with FPC 3.2.0 and up support.
https://www.raylib.com/
zlib License
98 stars 18 forks source link

GuiTextBox partialy functioning #14

Closed funlw65 closed 2 years ago

funlw65 commented 2 years ago

Hi Guya,

If the array of chars variable that is passed to GuiTextBox is attributed a value other than initializing it with '', outside the GuiTextBox, then this one will not allow editing the content of that variable. The following example works well, you can edit that variable as you like:

eText : array [0..60] of char = '';
iCategoryInput := GuiTextBox(rec_common, @eText, 60, true);

But if I touch the eText variable in any way, GuiTextBox will show its content but will not allow the editing;

These attributions:

eText := 'Spasiva!';`

or

eText := another_string_variable;

then eText is rendered non-editable in GuiTextBox, no matter if fpc is at 3.0.4 or 3.2.2 version.

I think (if is working the same also on your side) at least GuiTextBox must be rewritten in pascal.

I work at a visual demonstration program for qdbm database engine, in the way the example from fpc package is made for sqlite3 by ...pork... (can't remember his nickname), and I use raylib 4 with raygui from your translation.

GuvaCode commented 2 years ago
eText := 'Spasiva!';`

or


eText := another_string_variable;

Well, everything works for me.

program Game; {$mode objfpc}{$H+} uses

raygui, raylib;

const screenWidth = 800; screenHeight = 450;

var eText : array [0..60] of char = '';

begin InitWindow(screenWidth, screenHeight, 'raylib - simple project');

while not WindowShouldClose() do begin etext:='Hello '; BeginDrawing(); ClearBackground(RAYWHITE); GuiTextBox(RectangleCreate( 10, 30, 125, 30 ), @eText, 60, true); EndDrawing(); end; CloseWindow(); // Close window and OpenGL context end.

funlw65 commented 2 years ago

Thank you, I will try to see what and where I do wrong. I use a "form" with multiple GuiTextBox fields to edit the records of the database...

funlw65 commented 2 years ago

Your example presents the same problem I have... I'll see if is from compiling the C library...

GuvaCode commented 2 years ago

Could you show me your code?

funlw65 commented 2 years ago

No luck here, recompiled the GLFW 3.3.4 as shared lib, recompiled raylib 4 as shared with inclusion of raygui and physac...

Assured myself that I have the last version of your repository.

Now, as a note, I compile my app with fpc only, not using Lazarus. I have your .pas units in my folder and that is all.

In your little example, if I comment the line where:

eText := 'Hello';

then eText become editable. If not, it is only displayed, and the caret right after it, It does not move, no matter what I type.

If this will go well, I will share my app - it is intended from the start for sharing. If not, I will finish the app in C language to have an executable for everyone to play with it, and still sharing pascal sources for people that can use them.

funlw65 commented 2 years ago

I use Devuan 3.1.1 as OS.

GuvaCode commented 2 years ago

I use Devuan 3.1.1 as OS.

systemd is evil :)

funlw65 commented 2 years ago

:) Yeah, not evil, but not welcomed in my universe :). Well, I have nothing against others using it, it is becoming a standard and cannot be ignored. Having a machine with a systemd based linux for commercial application development is a must.

Gunko, I think you can close this issue. No matter the fpc version, I get the same behavior... And I am upset, because the application was almost finished. I tried also with 3.3.1 version... I think is because of my OS. I'll put this on hold, continue with C language, until I will be able to install something else. Thank you for this translation, it is really helpful.

funlw65 commented 2 years ago

Hi Gunko,

Your little example doesn't work even on your computer because you attribute the same value over and over again, no matter what you type in the GuiTextBox....

Move the attribution outside the while and the variable becomes editable.

That was my error.... now, to finish the example.