I would really recommend that you follow this learning path instead of other documentation
https://gettingstarted.mendixcloud.com/link/path/45
It does a great job explaining a lot of things on custom widget development that are not explained anywhere else.
-Andrej
You shoud use the mendix generator to initialize the boiler plate and start from that
Or alternatively have a look at the new Mendix plugable widget, available from Mendix 8
https://docs.mendix.com/howto/extensibility/pluggable-widgets