B4A Class NumericUpDown CustomView with Designer support

Discussion in 'Additional libraries, classes and official updates' started by Cableguy, May 3, 2015.

  1. Cableguy

    Cableguy Expert Licensed User

    Hi Guys...

    I'm not much of a Lib creator, but since B4A offers the possibility of compiling a class into a library, and me needing such a view, I created a very simple, yet fully functional Numeric Up and Down custom view.

    As the name suggests, It's a simple incremental/decremental view witch can either be added by code or in the designer.

    I share with you both the compiled library and the class. If you add functionality to the class, please do share...

    Special Thanks to @Filippo for creating years ago the first version of this view, and to @klaus for making me see the forest beyond those dahm trees!

    [EDIT] Ver. 1.15 - A small code error that prevented the view to be recognized by the designer is now hopefully fixed. Both Minus and Plus signs are now managed by canvas allowing for bigger and more readable buttons.

    [EDIT] Ver. 1.5 - New "AddToParent" keyword to enable adding the view by code
     

    Attached Files:

    Last edited: May 30, 2015
    Devan, asales, MarcoRome and 4 others like this.
  2. Cableguy

    Cableguy Expert Licensed User

    There's something strange happening in my lib/class.

    In the original Project, all works fine and compiles flawlessly, BUT, when I try to use my LIB on another project, The designer does not recognize it as a custom view, when added as a class, it does recognize it.
    But then, I get another problem... my compilation fails!

    I just cannot understand it, please advise!!
     
  3. klaus

    klaus Expert Licensed User

    I tried the Class. OK
    Then I compiled it to a library. OK
    Opened a new project, copied the code from the class project, checked the library and compiled it. OK.
    When you test the library do you still have the class module in the project ?
    If yes, you must remove it.
     
  4. Cableguy

    Cableguy Expert Licensed User

    I have tried 2 ways:

    add the view to the designer with the class - ok
    then save the layout(after generating members)
    remove the class, add the lib - the designer has changed the custom view type name but its still there, but nothing appears listed in the list, its blank... funny thing, compiled the project and works with no issues

    adding the lib to a blank project, the view is not recognised by the designer
     
    Last edited: May 7, 2015
  5. klaus

    klaus Expert Licensed User

    I did it the simple way, I copied the layout file from the other project.
    Now tried it your way and get the same problem, I don't see it in the Designer.
    The strange thing, with one of my own library I don't see it in the Designer, but with another one I see it.
    Have not yet found why. Will look furthet tomorrow.
     
  6. Cableguy

    Cableguy Expert Licensed User

    Thanks Klaus...It was driving me crazy not understanding were I was wrong... may be a glitch in the designer (?)
     
  7. klaus

    klaus Expert Licensed User

    Hi Paulo.
    I had a look at the problem to see what happens:

    1) I made a new class test project, compiled it to a library.
    Made a second project loading the library and adding the CustomView in the Designer worked.
    So this shows that B4A version 4.30 works OK with a new project.

    2) Then I made a new project for yor custom view, added a new class module, copied the whole code of your class into it and compiled it to a new library.
    Made a new project, tryes to add the CustomView in the Designer, no success, it doesn't appear.
    Then I saw in this class that the Public Sub DesignerCreateView(Base As Panel, lbl As Label, Props As Map) line was underlined with a warning.

    3) Then I made once again a new project at the beginning only the skeleton and where I wrote a new Public Sub DesignerCreateView(Base As Panel, lbl As Label, Props As Map) not copying from the other project.
    Compiled to a new library.
    Made another new project to test the library and the CustomView appears ?!
    Copied the rest of the code into the class, comiled the library and it works.

    So, I don't understand why this happens.
    I think that Erel should have a look at this.
    Because I have also libraries where the CustomView appears in the Designer and other libraries where it doesn't appear.

    Attached the two last working projects and the library files.
     

    Attached Files:

  8. Cableguy

    Cableguy Expert Licensed User

    Thaks for all your testing Klaus... I had seen the warning line about DesignerCreateView sub, but I thought it was due to the reason that this view is only used by the designer when loading the layout...
    We'll see what @Erel hás to say and hoppefully it will be solved on next update
     
    Last edited: May 9, 2015
  9. Cableguy

    Cableguy Expert Licensed User

    Well, this got me thinking about this... I had declared my DesignerCreateView as Private, thus the warning...
    Changing it to Public cleared the warning and the compiled lib seems to be recognized by the designer.
     
  10. Erel

    Erel Administrator Staff Member Licensed User

    That is true. The DesignerCreateView sub cannot be private. If it is private then the IDE cannot find it when you compile it to a library.
     
    Cableguy and klaus like this.
  11. klaus

    klaus Expert Licensed User

    I hadn't noticed that DesignerCreateView was declared as Private !?
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    I wrote it based on Cableguy's answer. Anyway lets wait with this for the next beta as all the relevant code is rewritten.
     
    DonManfred and Cableguy like this.
  13. Cableguy

    Cableguy Expert Licensed User

    New Ver.1.5 published, see post #1
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice