B4J Code Snippet B4XTable Column Resizing... (works for me)

Hi there...

Well many of us need/asking column resizing... but noone do the start... well I ve decided to start... but hey... need help.. I think is a good start... need a lot of fixes and your ideas...

I am uploading an example - and give you my notes here...

What works....
- Resizing Columns... smooth (in Release mode)
- Works only with columns had set their width, no auto-resize !!! Caution.
- When Resizing form works ok...
- Double-Click guideline hide column (width 1pixel)... double click again... restore width !!!

What not works...
- No with autoresizing columns / auto-width
- No for the moment with changed order columns
- When using scrollbar loosing the coordinates - you must go back...

(no b4xtable scrollbar event to check, a fix you can do is using timer and call every 500ms the enableresize, didn;t try it but i think will work)
Thanks to LucaMs !! ... fixed that too

What not tried...
- At B4A, B4I... please check them

My programming mistakes..
- Can't understand so good the b4xview and adding at root new items... so removefromview has errors... please fix it and tell me the way...
Erel told me the way !

Here a Video to see - how works... old-video now all working !


Is totally open-source - and ofcourse you can always donate me and B4X too.. Please share your code too... to make b4xtable stronger !

Credits to: Erel, LucaMs, Mahares, aeric...

You can donate me (buy me a coffee, drink, etc) If you think I've helped you...
 

Attachments

  • B4XTableExample-column-resizing-NEW2.zip
    55.7 KB · Views: 352
  • AnimationDONATE.gif
    10.7 KB · Views: 243
  • AnimationDONATE2.gif
    10.8 KB · Views: 7,604
Last edited:

Mahares

Expert
Licensed User
Longtime User
What works
You show a video that looks like it is working, the title of your threead says: not fully working, but the project crashes with following error. So what is the verdict.
B4X:
B4J line: 154
headerpanel.As(B4XView)=xui.CreatePanel(\
shell\src\b4j\example\b4xmainpage_subs_0.java:568: error: as of release 9, '_' is a keyword, and may not be used as an identifier
(__ref.getField(false,"_headerpanel" /*RemoteObject*/ )) = __ref.getField(false,"_xui" /*RemoteObject*/ ).runMethod(false,"CreatePanel",__ref.getField(false, "ba"),(Object)(RemoteObject.createImmutable("headerpanel")));Debug.locals.put("", _);
                                                                                                                                                                                                                                                ^
1 error
 

Magma

Expert
Licensed User
Longtime User
but it works-not lying.. wait a little i will upload an update with some new features..
 

Magma

Expert
Licensed User
Longtime User
updated...

Added double click to restore width - hide column (width:1 dip)
Added Timer to check scrollbar x (so... now you can move the scrollbar too)

...I think now it is someway ready... if someone want to to work with the order of columns be my guest... also... if someone find the way to calculate searchbox, buttons height or scrollbar height (is easy i think).. .tell me to fix it...
 

Magma

Expert
Licensed User
Longtime User
Found what was....

When packing to zip from b4j menu... for some reason these lines give error:

B4X:
#Region Shared Files
#CustomBuildAction: folders ready, %WINDIR%\System32\Robocopy.exe,"..\..\Shared Files" "..\Files"
'Ctrl + click to sync files: ide://run?file=%WINDIR%\System32\Robocopy.exe&args=..\..\Shared+Files&args=..\Files&FilesSync=True
#End Region

'Ctrl + click to export as zip: ide://run?VMArgs=-DZeroSharedFiles%3DTrue&File=%B4X%\Zipper.jar&Args=B4XTableExample.zip

please remove them... and will work !... but first download the new zip... i think already removed... and has new features...
 

Mahares

Expert
Licensed User
Longtime User
please remove them... and will work !... but first download the new zip... i think already removed... and has new features...
Sorry. Even with your new version I have the same problem. It has nothing to do with what you mentioned as the reason in post#5. Maybe someone can report to you if it worked for them, then I do not know what my problem is. Maybe someone else can tell us. ANyway, thank you, I do not have to have that feature, as I do not need it. I just wanted to help by testing it.

B4X:
B4J Version: 9.30
Parsing code.    (0.13s)
    Java Version: 11
Building folders structure.    (0.15s)
Compiling code.    (0.29s)
Compiling layouts code.    (0.02s)
Organizing libraries.    (0.00s)
Compiling generated Java code.    (3.55s)
Compiling debugger engine code.    Error
B4J line: 172
headerpanel.As(B4XView)=xui.CreatePanel(\
shell\src\b4j\example\b4xmainpage_subs_0.java:592: error: as of release 9, '_' is a keyword, and may not be used as an identifier
(__ref.getField(false,"_headerpanel" /*RemoteObject*/ )) = __ref.getField(false,"_xui" /*RemoteObject*/ ).runMethod(false,"CreatePanel",__ref.getField(false, "ba"),(Object)(RemoteObject.createImmutable("headerpanel")));Debug.locals.put("", _);
                                                                                                                                                                                                                                                ^
1 error
 

Magma

Expert
Licensed User
Longtime User
Very strange...
I would like to listen other members too..

Today I am not in office/on PC ... to check the zip again..

Or screenshot libs using.. I am not remember anything special... is just the example of b4xtable erel made old days

+testing done with Release only if that helps...

Ps: as I am reading your post (Mahares, I understand that you using debug mode.. As I remember I was testing in Release mode)
 
Last edited:

Mahares

Expert
Licensed User
Longtime User
Ps: as I am reading your post (Mahares, I understand that you using debug mode.. As I remember I was testing in Release mode)
It runs in release, but crashes in debug. Now, I can check it out. I am surprised no one that tested it did not bring it up to our attention earlier.
ευχαριστώ
 

aeric

Expert
Licensed User
Longtime User

I have eliminate the error by removing the casting:

B4X:
hheaderpanel = xui.CreatePanel("hhheaderpanel")

It runs in release, but crashes in debug.
The crash in debug happened in hhheaderpanel_MouseExited when the Sender is null and I may have fixed/bypassed it with the following:

B4X:
Private Sub hhheaderpanel_MouseExited (EventData As MouseEvent)
    If EventData.PrimaryButtondown Then Return
    Dim pane1 As B4XView = Sender
    ' modified by aeric
    Log(Sender)
    'pane1.SetColorAndBorder(xui.Color_Transparent, 2,0,0)
    If pane1.IsInitialized Then
        pane1.SetColorAndBorder(xui.Color_Transparent, 2, 0, 0)
    End If
End Sub

And I am not sure the following help but I think no harm to add it inside Sub Class_Globals:
B4X:
#RaisesSynchronousEvents: hhheaderpanel


P/S: I thought to change the mouse cursor using
B4X:
pane1.As(Pane).MouseCursor = fx.Cursors.H_RESIZE
but H_RESIZE does not exist.
 

Magma

Expert
Licensed User
Longtime User
when you say... removing the cast... ? how did you add the pane... as simple pane ?

a code... or a zip will be helpful for all...

did anyone tried at b4a or thought a way to use there ?
I have eliminate the error by removing the casting:

B4X:
hheaderpanel = xui.CreatePanel("hhheaderpanel")
 

aeric

Expert
Licensed User
Longtime User
when you say... removing the cast... ? how did you add the pane... as simple pane ?
You already define the variable hheaderpanel As B4XView in Class_Globals on top:
B4X:
'added by MAGMA:
Dim hheaderpanel As B4XView
So you do not require to cast it again as B4XView.
B4X:
' modified by aeric
'hheaderpanel.As(B4XView) = xui.CreatePanel("hhheaderpanel")
hheaderpanel = xui.CreatePanel("hhheaderpanel")
 

Attachments

  • B4XTableExample.zip
    55.8 KB · Views: 237

Magma

Expert
Licensed User
Longtime User

Magma

Expert
Licensed User
Longtime User
no... getting ... after some mouseovers and after scolling horizantal... errors:

 

Magma

Expert
Licensed User
Longtime User
P/S: I thought to change the mouse cursor using
B4X:
pane1.As(Pane).MouseCursor = fx.Cursors.H_RESIZE
but H_RESIZE does not exist.

B4X:
        Dim cursor As JavaObject
        cursor.InitializeStatic("javafx.scene.Cursor")

        Dim joObj As JavaObject = pane1
        joObj.RunMethod("setCursor", Array(cursor.GetField("E_RESIZE")))
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…