Automatically detect length of widget array