Posted January 17, 20232 yr As in the topic, I am using this code. The button text is obscured by the tooltip but the button itself is not, I don't know how to fix it. public void renderButton(PoseStack poseStack, int pMouseX, int pMouseY, float pPartialTick) { Minecraft mc = Minecraft.getInstance(); int k = this.getYImage(this.isHovered); ScreenUtils.blitWithBorder(poseStack, WIDGETS_LOCATION, this.x, this.y, 0, 46 + k * 20, this.width, this.height, 200, 20, 2, 3, 2, 2, this.getBlitOffset()); this.renderBg(poseStack, mc, pMouseX, pMouseY); Component buttonText = this.getMessage(); int strWidth = mc.font.width(buttonText); int ellipsisWidth = mc.font.width("..."); if (strWidth > width - 6 && strWidth > ellipsisWidth) buttonText = Component.literal(mc.font.substrByWidth(buttonText, width - 6 - ellipsisWidth).getString() + "..."); drawCenteredString(poseStack, mc.font, buttonText, this.x + this.width / 2, this.y + (this.height - 8) / 2, getFGColor()); if(this.isHoveredOrFocused()){ this.renderToolTip(poseStack, pMouseX, pMouseY); } }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.